Skip to content

Commit 9e5013c

Browse files
author
Paultagoras
committed
Adjust tests
1 parent e613793 commit 9e5013c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaData.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,10 @@ public ResultSet getPrimaryKeys(String catalog, String schema, String table) thr
919919
"FROM system.tables " +
920920
"ARRAY JOIN arrayZip(splitByChar(',', primary_key), arrayEnumerate(splitByChar(',', primary_key))) as c " +
921921
"WHERE system.tables.primary_key <> '' " +
922-
"AND system.tables.database LIKE '" + (schema == null ? "%" : schema) + "' " +
923-
"AND system.tables.name LIKE '" + (table == null ? "%" : table) + "'";
922+
"AND system.tables.database ILIKE '" + (schema == null ? "%" : schema) + "' " +
923+
"AND system.tables.name ILIKE '" + (table == null ? "%" : table) + "' " +
924+
"ORDER BY TABLE_SCHEM, TABLE_NAME, KEY_SEQ";
925+
log.debug("getPrimaryKeys: %s", sql);
924926
return connection.createStatement().executeQuery(sql);
925927
} catch (Exception e) {
926928
throw ExceptionUtils.toSqlState(e);

jdbc-v2/src/test/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,20 @@ public void testGetTables() throws Exception {
9898
}
9999
}
100100

101-
//@Ignore("ClickHouse does not support primary keys")
101+
102102
@Test(groups = { "integration" })
103103
public void testGetPrimaryKeys() throws Exception {
104104
try (Connection conn = getJdbcConnection()) {
105105
DatabaseMetaData dbmd = conn.getMetaData();
106-
ResultSet rs = dbmd.getPrimaryKeys(null, "system", "numbers");
106+
ResultSet rs = dbmd.getPrimaryKeys(null, "system", "query_log");
107107
assertTrue(rs.next());
108-
assertEquals(rs.getString("TABLE_NAME"), "numbers");
109-
assertEquals(rs.getString("COLUMN_NAME"), "number");
108+
assertEquals(rs.getString("TABLE_NAME"), "query_log");
109+
assertEquals(rs.getString("COLUMN_NAME"), "event_date");
110110
assertEquals(rs.getShort("KEY_SEQ"), 1);
111+
assertTrue(rs.next());
112+
assertEquals(rs.getString("TABLE_NAME"), "query_log");
113+
assertEquals(rs.getString("COLUMN_NAME"), "event_time");
114+
assertEquals(rs.getShort("KEY_SEQ"), 2);
111115
assertFalse(rs.next());
112116
}
113117
}

0 commit comments

Comments
 (0)