Skip to content

Commit

Permalink
SNOW-1844765 Make createArrayOf case-insensitive (#2010)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mkubik authored Dec 19, 2024
1 parent b3a2763 commit 0251382
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ public String getClientInfo(String name) throws SQLException {
@Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
logger.trace("Array createArrayOf(String typeName, Object[] " + "elements)", false);
return new SfSqlArray(JDBCType.valueOf(typeName).getVendorTypeNumber(), elements);
return new SfSqlArray(JDBCType.valueOf(typeName.toUpperCase()).getVendorTypeNumber(), elements);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,11 @@ public void testWriteArray(ResultSetFormatType queryResultFormat) throws SQLExce
statement.execute(" CREATE OR REPLACE TABLE array_of_integers(arrayInt ARRAY(INTEGER))");

Array array = connection.createArrayOf("INTEGER", new Integer[] {1, 2, 3});
Array arrayFromLowerCaseType = connection.createArrayOf("integer", new Integer[] {1, 2, 3});
stmt.setArray(1, array);
stmt.executeUpdate();
stmt.setArray(1, arrayFromLowerCaseType);
stmt.executeUpdate();

try (ResultSet resultSet = statement.executeQuery("SELECT * from array_of_integers"); ) {
resultSet.next();
Expand All @@ -282,6 +285,10 @@ public void testWriteArray(ResultSetFormatType queryResultFormat) throws SQLExce
assertEquals(Long.valueOf(1), resultArray[0]);
assertEquals(Long.valueOf(2), resultArray[1]);
assertEquals(Long.valueOf(3), resultArray[2]);

resultSet.next();
Long[] resultArrayFromLowerCaseType = (Long[]) resultSet.getArray(1).getArray();
assertArrayEquals(resultArray, resultArrayFromLowerCaseType);
}
}
}
Expand Down

0 comments on commit 0251382

Please sign in to comment.