summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-10-22 23:21:00 +0800
committerKeuin <[email protected]>2023-10-22 23:21:00 +0800
commitd468e2f524022b1b1e5fe0e1d58a4efcc6583545 (patch)
tree4a95fce36ec56972bb64f53ac3bb43b784b6da30 /src/main/java
parent0f5ea8826d1cecf7addf0cfcaa5771a9839a75b2 (diff)
bugfix: SQL syntax error in some environment
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/keuin/blame/lookup/QueryExecutor.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/java/com/keuin/blame/lookup/QueryExecutor.java b/src/main/java/com/keuin/blame/lookup/QueryExecutor.java
index da25064..e11cdda 100644
--- a/src/main/java/com/keuin/blame/lookup/QueryExecutor.java
+++ b/src/main/java/com/keuin/blame/lookup/QueryExecutor.java
@@ -30,7 +30,7 @@ public class QueryExecutor {
// ClickHouse driver's parameterized SQL generator is a piece of shit.
// I won't use that. Use string interpolation instead.
var sql = "select subject_id, object_id, action_type, ts";
- sql += " from " + escape(DatabaseUtil.DB_CONFIG.getTable());
+ sql += " from " + escapeIdentifier(DatabaseUtil.DB_CONFIG.getTable());
sql += " where subject_world=%s and object_x=%d and object_y=%d and object_z=%d".formatted(
escape(world), x, y, z
);
@@ -47,6 +47,10 @@ public class QueryExecutor {
return "'" + s.replace("\\", "\\\\").replace("'", "\\'") + "'";
}
+ private static String escapeIdentifier(String s) {
+ return "\"" + s.replace("\\", "\\\\").replace("\"", "\"\"") + "\"";
+ }
+
public void byBlockPos(
String world,
long x, long y, long z,