Skip to content

Commit f930097

Browse files
committed
fixed SQL insert to table with name eq keyword
1 parent 9993564 commit f930097

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ParsedPreparedStatement.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,18 @@ private void appendParameter(int startIndex) {
211211
}
212212
}
213213

214+
@Override
215+
public void enterTableExprIdentifier(ClickHouseParser.TableExprIdentifierContext ctx) {
216+
if (ctx.tableIdentifier() != null) {
217+
this.table = SqlParser.unquoteIdentifier(ctx.tableIdentifier().getText());
218+
}
219+
}
220+
214221
@Override
215222
public void enterInsertStmt(ClickHouseParser.InsertStmtContext ctx) {
216223
ClickHouseParser.TableIdentifierContext tableId = ctx.tableIdentifier();
217224
if (tableId != null) {
218-
this.table = tableId.identifier().IDENTIFIER().getText();
225+
this.table = SqlParser.unquoteIdentifier(tableId.getText());
219226
}
220227

221228
ClickHouseParser.ColumnsClauseContext columns = ctx.columnsClause();

jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/SqlParserTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ public Object[][] testMiscStmtDp() {
294294
{"SELECT * FROM table test WHERE ts = ?", 1},
295295
{"SELECT * FROM table view WHERE ts = ?", 1},
296296
{"SELECT * FROM table primary WHERE ts = ?", 1},
297+
{"insert into events (s) values ('a')", 0},
298+
{"insert into `events` (s) values ('a')", 0},
297299
};
298300
}
299301
}

0 commit comments

Comments
 (0)