Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ public boolean isDefinitelyWritable(int column) throws SQLException {
@Override
public String getColumnClassName(int column) throws SQLException {
try {
return typeClassMap.getOrDefault(getColumn(column).getDataType(), Object.class).getName();
Class<?> columnClassType = typeClassMap.get(getColumn(column).getDataType());
if (columnClassType == null) {
columnClassType = Object.class;
}
return columnClassType.getName();
} catch (Exception e) {
throw ExceptionUtils.toSqlState(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ public void testGetColumnTypeIntegers() throws Exception {
}
}

@Test
public void testGetColumnTypeMap() throws Exception {
try (Connection conn = getJdbcConnection()) {
try (Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery("select map('a', 1) as a");
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(rsmd.getColumnType(1), Types.JAVA_OBJECT);
assertEquals(rsmd.getColumnClassName(1), Object.class.getName());
Comment on lines +84 to +87
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using try-with-resources for ResultSet to ensure it’s closed explicitly, e.g., try (ResultSet rs = stmt.executeQuery(...)).

Suggested change
ResultSet rs = stmt.executeQuery("select map('a', 1) as a");
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(rsmd.getColumnType(1), Types.JAVA_OBJECT);
assertEquals(rsmd.getColumnClassName(1), Object.class.getName());
try (ResultSet rs = stmt.executeQuery("select map('a', 1) as a")) {
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(rsmd.getColumnType(1), Types.JAVA_OBJECT);
assertEquals(rsmd.getColumnClassName(1), Object.class.getName());
}

Copilot uses AI. Check for mistakes.
}
}
}

@Test(groups = { "integration" })
public void testGetColumnTypeFloats() throws Exception {
try (Connection conn = getJdbcConnection()) {
Expand Down
Loading