diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/keuin/blame/lookup/QueryExecutor.java | 6 |
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, |