Skip to content

Commit 820f878

Browse files
RizlimRizlim
authored andcommitted
1.11.1 hotfix ; I hate SQL
1 parent 0fbd95d commit 820f878

File tree

3 files changed

+41
-40
lines changed

3 files changed

+41
-40
lines changed

src/main/kotlin/PAL2/Database/DataBaseHandler.kt

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,24 @@ fun syncGlobalWithDB()
3737
{
3838
val connection = connectToDB()
3939
connection.createStatement().executeUpdate("update Flags set launch_poe_on_pal_launch = ${GlobalData.launchPOEonLaunch}, Steam_POE = ${GlobalData.steam_poe}, GitHub_API = ${GlobalData.gitHubAPIEnabled}, show_motd = ${GlobalData.showUpdateNotesOnUpdate}")
40-
connection.createStatement().executeUpdate("update Addons_Folder set location = \"${GlobalData.addonFolder}\", `primary` = 1;")
40+
connection.createStatement().executeUpdate("update Addons_Folder set location = \'${GlobalData.addonFolder}\', `primary` = 1;")
4141
connection.createStatement().executeUpdate("update Meta set " +
42-
"loot_filter_folder = \"${GlobalData.loot_filter_path}\"," +
43-
"ahk_folder = \"${GlobalData.ahkFolder.path}\", " +
44-
"github_API_token = \"${GlobalData.github_token}\", " +
45-
"temp_down_folder = \"${GlobalData.temp_down_folder}\";")
42+
"loot_filter_folder = \'${GlobalData.loot_filter_path}\'," +
43+
"ahk_folder = \'${GlobalData.ahkFolder.path}\', " +
44+
"github_API_token = \'${GlobalData.github_token}\', " +
45+
"temp_down_folder = \'${GlobalData.temp_down_folder}\';")
4646

4747
val primaryPoE = GlobalData.primaryPoEFile
4848
if (primaryPoE != null)
4949
{
5050
connection.createStatement().execute("delete from PoE_Locations where `primary` = true")
51-
val rs = connection.createStatement().executeQuery("select count(*) from PoE_Locations where location = \"${primaryPoE.path}\";")
51+
val rs = connection.createStatement().executeQuery("select count(*) from PoE_Locations where location = \'${primaryPoE.path}\';")
5252
val c = rs.getInt(1)
5353
if (c > 0)
5454
{
55-
connection.createStatement().execute("delete from PoE_Locations where location = \"${primaryPoE.path}\"")
55+
connection.createStatement().execute("delete from PoE_Locations where location = \'${primaryPoE.path}\'")
5656
}
57-
connection.createStatement().execute("insert into PoE_Locations values (\"${primaryPoE.path}\", true);")
57+
connection.createStatement().execute("insert into PoE_Locations values (\'${primaryPoE.path}\', true);")
5858
}
5959

6060
syncAHKScripts(connection)
@@ -68,11 +68,11 @@ fun syncPoEFolders(connection: Connection)
6868
val poe = GlobalData.poeLocations
6969
for (s in poe)
7070
{
71-
val rs = connection.createStatement().executeQuery("select count(*) from PoE_Locations where location = \"$s\";")
71+
val rs = connection.createStatement().executeQuery("select count(*) from PoE_Locations where location = \'$s\';")
7272
val c = rs.getInt(1)
7373
if (c == 0)
7474
{
75-
connection.createStatement().execute("insert into PoE_Locations values (\"$s\", false);")
75+
connection.createStatement().execute("insert into PoE_Locations values (\'$s\', false);")
7676
}
7777
}
7878
}
@@ -83,35 +83,35 @@ fun syncAHKScripts(connection: Connection)
8383

8484
for (s in scripts)
8585
{
86-
val rs = connection.createStatement().executeQuery("select count(*) from AHK_Scripts where location = \"$s\";")
86+
val rs = connection.createStatement().executeQuery("select count(*) from AHK_Scripts where location = \'$s\';")
8787
val c = rs.getInt(1)
8888
if (c == 0)
8989
{
90-
connection.createStatement().execute("insert into AHK_Scripts values (\"$s\", true);")
90+
connection.createStatement().execute("insert into AHK_Scripts values (\'$s\', true);")
9191
}
9292
}
9393
}
9494

9595
fun removeAHKscript(string: String)
9696
{
9797
val connection = connectToDB()
98-
val rs = connection.createStatement().executeQuery("select count(*) from AHK_Scripts where location = \"$string\";")
98+
val rs = connection.createStatement().executeQuery("select count(*) from AHK_Scripts where location = \'$string\';")
9999
val c = rs.getInt(1)
100100
if (c > 0)
101101
{
102-
connection.createStatement().execute("delete from AHK_Scripts where location = \"$string\"")
102+
connection.createStatement().execute("delete from AHK_Scripts where location = \'$string\'")
103103
}
104104
connection.close()
105105
}
106106

107107
fun removePoELoc(string: String)
108108
{
109109
val connection = connectToDB()
110-
val rs = connection.createStatement().executeQuery("select count(*) from PoE_Locations where location = \"$string\";")
110+
val rs = connection.createStatement().executeQuery("select count(*) from PoE_Locations where location = \'$string\';")
111111
val c = rs.getInt(1)
112112
if (c > 0)
113113
{
114-
connection.createStatement().execute("delete from PoE_Locations where location = \"$string\";")
114+
connection.createStatement().execute("delete from PoE_Locations where location = \'$string\';")
115115
}
116116
connection.close()
117117
}
@@ -127,11 +127,11 @@ fun updateRunAddonWhenLaunching(runOnLaunch: Boolean, aid: Int)
127127
fun updateAddonConfig(lc: String, installDir: String, aid: Int, addonName: String, version:String, runOnLaunch: Boolean)
128128
{
129129
val connection = connectToDB()
130-
connection.createStatement().executeUpdate("update InstalledAddon set name = \"$addonName\", " +
131-
"install_location = \"$installDir\", " +
132-
"version = \"$version\", " +
133-
"last_update = \"${createDate(LocalDate.now())}\", " +
134-
"launch_command = \"$lc\", " +
130+
connection.createStatement().executeUpdate("update InstalledAddon set name = \'$addonName\', " +
131+
"install_location = \'$installDir\', " +
132+
"version = \'$version\', " +
133+
"last_update = \'${createDate(LocalDate.now())}\', " +
134+
"launch_command = \'$lc\', " +
135135
"run_on_launch = $runOnLaunch " +
136136
"WHERE aid = $aid;")
137137
connection.close()
@@ -199,7 +199,7 @@ fun getLaunchCommand(aid: Int): String
199199
fun updateLaunchCommandInstalledAddon(launch_command: String, aid: Int)
200200
{
201201
val connection = connectToDB()
202-
connection.createStatement().execute("UPDATE InstalledAddon set launch_command = \"$launch_command\" where aid = $aid;")
202+
connection.createStatement().execute("UPDATE InstalledAddon set launch_command = \'$launch_command\' where aid = $aid;")
203203
connection.close()
204204
}
205205

@@ -216,7 +216,7 @@ fun addInstalledAddon(afd: PAL_AddonFullData, installLocation: File)
216216
}
217217
connection = connectToDB()
218218

219-
connection.createStatement().execute("Insert into InstalledAddon values (${afd.aid}, \"${afd.name}\", \"$installLocation\", \"${afd.version_text}\", \"${LocalDate.now()}\", \"?\", \"?\", false)")
219+
connection.createStatement().execute("Insert into InstalledAddon values (${afd.aid}, \'${afd.name}\', \'$installLocation\', \'${afd.version_text}\', \'${LocalDate.now()}\', \'?\', \'?\', false)")
220220
connection.close()
221221
}
222222

@@ -326,7 +326,7 @@ fun getExternalsOnLaunchCommands(): Array<String>?
326326
fun doesTableExist(table: String): Boolean
327327
{
328328
val connection = connectToDB()
329-
val rs = connection.createStatement().executeQuery("SELECT COUNT(*) FROM sqlite_master WHERE name =\"$table\" and type='table'; ")
329+
val rs = connection.createStatement().executeQuery("SELECT COUNT(*) FROM sqlite_master WHERE name =\'$table\' and type='table'; ")
330330
val res = rs.getInt(1)
331331
connection.close()
332332
return res != 0
@@ -425,7 +425,7 @@ fun getLastPALVersion(): String
425425
fun setPALVersion()
426426
{
427427
val connection = connectToDB()
428-
connection.createStatement().executeUpdate("UPDATE Meta set pal_version = \"${GlobalData.version}\";")
428+
connection.createStatement().executeUpdate("UPDATE Meta set pal_version = \'${GlobalData.version}\';")
429429
connection.close()
430430
}
431431

@@ -448,7 +448,7 @@ fun insertConfiguratorData(config: Configurator)
448448
{
449449
for (f in config.poeFolder!!)
450450
{
451-
connection.createStatement().execute("INSERT into POE_Locations values(\"${f.path}\", false )")
451+
connection.createStatement().execute("INSERT into POE_Locations values(\'${f.path}\', false )")
452452
GlobalData.poeLocations.add(f.path)
453453
}
454454
}
@@ -460,9 +460,9 @@ fun insertConfiguratorData(config: Configurator)
460460
{
461461
addonFolder = config.addonfolder!!.path
462462
}
463-
connection.createStatement().execute("INSERT into Addons_Folder values (\"$addonFolder\", true);")
463+
connection.createStatement().execute("INSERT into Addons_Folder values (\'$addonFolder\', true);")
464464
connection.createStatement().execute("INSERT into Flags values (${config.launchPOEonLaunch}, ${config.useSteamPoE}, ${config.githubAPIenabled}, ${config.showUpdateNotesOnUpdate});")
465-
connection.createStatement().execute("INSERT into Meta values (\"\", \"${ahkFolder}\", \"${GlobalData.version}\", \"${config.githubToken}\", \"${config.tempDownFolder}\");")
465+
connection.createStatement().execute("INSERT into Meta values (\'\', \'${ahkFolder}\', \'${GlobalData.version}\', \'${config.githubToken}\', \'${config.tempDownFolder}\');")
466466
connection.close()
467467

468468
GlobalData.addonFolder = File(addonFolder)
@@ -524,7 +524,7 @@ fun insertExternalAddonIntoDB(ea: PAL_External_Addon)
524524
fun getSetting(string: String): String
525525
{
526526
val connection = connectToDB()
527-
val sql = "SELECT value from Settings WHERE name = \"$string\";"
527+
val sql = "SELECT value from Settings WHERE name = \'$string\';"
528528
val rs = connection.createStatement().executeQuery(sql)
529529
val res = rs.getString(1)
530530
connection.close()
@@ -534,25 +534,25 @@ fun getSetting(string: String): String
534534
fun putSetting(name: String, value: String)
535535
{
536536
val connection = connectToDB()
537-
val sql = "UPDATE Settings set value = \"$value\" WHERE name = \"$name\";"
537+
val sql = "UPDATE Settings set value = \'$value\' WHERE name = \'$name\';"
538538
connection.createStatement().execute(sql)
539539
connection.close()
540540
}
541541

542542
fun filterSettingsCheck(): FilterSettings
543543
{
544544
val connection = connectToDB()
545-
var rs = connection.createStatement().executeQuery("SELECT COUNT(*) FROM Settings WHERE name = \"f_min\"")
545+
var rs = connection.createStatement().executeQuery("SELECT COUNT(*) FROM Settings WHERE name = \'f_min\'")
546546
val c = rs.getInt(1)
547547

548548
if (c == 0)
549549
{
550550
// Create initial values
551-
var sql = "INSERT into Settings values (\"f_min\", 60);"
551+
var sql = "INSERT into Settings values (\'f_min\', 60);"
552552
connection.createStatement().execute(sql)
553-
sql = "INSERT into Settings values(\"not_f_update_during_poe\", 1);"
553+
sql = "INSERT into Settings values(\'not_f_update_during_poe\', 1);"
554554
connection.createStatement().execute(sql)
555-
sql = "INSERT into Settings values(\"auto_f_update\", 0)"
555+
sql = "INSERT into Settings values(\'auto_f_update\', 0)"
556556
connection.createStatement().execute(sql)
557557
connection.close()
558558
return FilterSettings(60, true, false)
@@ -683,7 +683,7 @@ fun hideExternalAddon(eid: Int)
683683
return
684684

685685
val connection = connectToDB()
686-
connection.createStatement().executeUpdate("UPDATE ExternalAddon set name = \"3c484944453e\" WHERE eid = $eid;")
686+
connection.createStatement().executeUpdate("UPDATE ExternalAddon set name = \'3c484944453e\' WHERE eid = $eid;")
687687
connection.close()
688688
updateRunOnLaunchExternal(eid, false)
689689
}
@@ -716,7 +716,7 @@ fun updateFilter(filter: Filter)
716716
return
717717
}
718718

719-
val sql = "UPDATE Filters set crc32 = \"${filter.crc32}\" where fid = ${filter.fid};"
719+
val sql = "UPDATE Filters set crc32 = \'${filter.crc32}\' where fid = ${filter.fid};"
720720
val connection = connectToDB()
721721
connection.createStatement().executeUpdate(sql)
722722
connection.close()
@@ -741,7 +741,7 @@ fun updateExternalAddon(ea: PAL_External_Addon)
741741
"WHERE eid = ${ea.eid};"
742742

743743
val connection = connectToDB()
744-
logger.debug { "Connected to DB executing SQL: \"$sql\"" }
744+
logger.debug { "Connected to DB executing SQL: \'$sql\'" }
745745
connection.createStatement().executeUpdate(sql)
746746
connection.close()
747747
}
@@ -776,7 +776,7 @@ fun createTables(connection: Connection)
776776

777777
connection.createStatement().execute("CREATE TABLE IF NOT EXISTS Addons_Folder (\n" +
778778
" location text NOT NULL,\n" +
779-
" \"primary\" boolean NOT NULL\n" +
779+
" \'primary\' boolean NOT NULL\n" +
780780
");")
781781

782782
connection.createStatement().execute("CREATE TABLE IF NOT EXISTS CustomPrograms (\n" +
@@ -820,7 +820,7 @@ fun createTables(connection: Connection)
820820

821821
connection.createStatement().execute("CREATE TABLE IF NOT EXISTS PoE_Locations (\n" +
822822
" location text NOT NULL,\n" +
823-
" \"primary\" boolean NOT NULL\n" +
823+
" \'primary\' boolean NOT NULL\n" +
824824
");")
825825

826826
connection.createStatement().execute("CREATE TABLE IF NOT EXISTS Repos (\n" +

src/main/kotlin/PAL2/GlobalData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class GlobalData
1010
{
1111
companion object
1212
{
13-
var version = "1.11"
13+
var version = "1.11.1"
1414
var debugging = false
1515
var install_dir = ""
1616
var github_token = ""

src/main/resources/update_notes.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<li>Fix some bugs with Externals</li>
6666
<li>FilterBlast Loot Filters support</li>
6767
<li>Generally Code enhancements</li>
68+
<li>Hotfix: SQL sux ok</li>
6869
</ul>
6970

7071
<div class="block_1 hline-bottom"><h1>Version 1.0.10</h1></div>

0 commit comments

Comments
 (0)