Skip to content

Commit

Permalink
Adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paultagoras committed Dec 6, 2024
1 parent e613793 commit 9e5013c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,10 @@ public ResultSet getPrimaryKeys(String catalog, String schema, String table) thr
"FROM system.tables " +
"ARRAY JOIN arrayZip(splitByChar(',', primary_key), arrayEnumerate(splitByChar(',', primary_key))) as c " +
"WHERE system.tables.primary_key <> '' " +
"AND system.tables.database LIKE '" + (schema == null ? "%" : schema) + "' " +
"AND system.tables.name LIKE '" + (table == null ? "%" : table) + "'";
"AND system.tables.database ILIKE '" + (schema == null ? "%" : schema) + "' " +
"AND system.tables.name ILIKE '" + (table == null ? "%" : table) + "' " +
"ORDER BY TABLE_SCHEM, TABLE_NAME, KEY_SEQ";
log.debug("getPrimaryKeys: %s", sql);
return connection.createStatement().executeQuery(sql);
} catch (Exception e) {
throw ExceptionUtils.toSqlState(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,20 @@ public void testGetTables() throws Exception {
}
}

//@Ignore("ClickHouse does not support primary keys")

@Test(groups = { "integration" })
public void testGetPrimaryKeys() throws Exception {
try (Connection conn = getJdbcConnection()) {
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getPrimaryKeys(null, "system", "numbers");
ResultSet rs = dbmd.getPrimaryKeys(null, "system", "query_log");
assertTrue(rs.next());
assertEquals(rs.getString("TABLE_NAME"), "numbers");
assertEquals(rs.getString("COLUMN_NAME"), "number");
assertEquals(rs.getString("TABLE_NAME"), "query_log");
assertEquals(rs.getString("COLUMN_NAME"), "event_date");
assertEquals(rs.getShort("KEY_SEQ"), 1);
assertTrue(rs.next());
assertEquals(rs.getString("TABLE_NAME"), "query_log");
assertEquals(rs.getString("COLUMN_NAME"), "event_time");
assertEquals(rs.getShort("KEY_SEQ"), 2);
assertFalse(rs.next());
}
}
Expand Down

0 comments on commit 9e5013c

Please sign in to comment.