Skip to content

Commit 2b108b0

Browse files
committed
fixed in statement with multiple arguments
1 parent 8b2406e commit 2b108b0

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,9 +1375,9 @@ public void testCTEWithUnboundCol() throws Exception {
13751375
public void testWithInClause() throws Exception {
13761376

13771377
try (Connection conn = getJdbcConnection()) {
1378-
String cte = "select number from system.numbers where number in (?) limit 10";
1379-
Long[] filter = new Long[]{2L, 4L, 6L};
1380-
try (PreparedStatement stmt = conn.prepareStatement(cte)) {
1378+
final String q1 = "select number from system.numbers where number in (?) limit 10";
1379+
try (PreparedStatement stmt = conn.prepareStatement(q1)) {
1380+
Long[] filter = new Long[]{2L, 4L, 6L};
13811381
stmt.setArray(1, conn.createArrayOf("Int64", filter));
13821382
ResultSet rs = stmt.executeQuery();
13831383

@@ -1387,6 +1387,21 @@ public void testWithInClause() throws Exception {
13871387
}
13881388
Assert.assertFalse(rs.next());
13891389
}
1390+
1391+
final String q2 = "with t as (select arrayJoin([1, 2, 3]) as a ) select * from t where a in(?, ?)";
1392+
try (PreparedStatement stmt = conn.prepareStatement(q2)) {
1393+
Long[] filter = new Long[]{2L, 3L};
1394+
1395+
stmt.setInt(1, 2);
1396+
stmt.setInt(2, 3);
1397+
ResultSet rs = stmt.executeQuery();
1398+
1399+
for (Long filterValue : filter) {
1400+
assertTrue(rs.next());
1401+
assertEquals(rs.getLong(1), filterValue);
1402+
}
1403+
Assert.assertFalse(rs.next());
1404+
}
13901405
}
13911406
}
13921407

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ public Object[][] testMiscStmtDp() {
283283
{"alter table user delete where reg_time = ?", 1},
284284
{"SELECT * FROM a,b WHERE id > ?", 1},
285285
{"select ip from myusers where tenant=?", 1},
286+
{"SELECT myColumn FROM myTable WHERE myColumn in (?, ?, ?)", 3},
286287
{"DROP USER IF EXISTS default_impersonation_user", 0},
287288
{"DROP ROLE IF EXISTS `vkonfwxapllzkkgkqdvt`", 0},
288289
{"CREATE ROLE `kjxrsscptauligukwgmf` ON CLUSTER '{cluster}'", 0},

0 commit comments

Comments
 (0)