Skip to content

Commit

Permalink
fixed warnings and added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexradzin committed Jun 2, 2024
1 parent 1bd18d8 commit 40d9d86
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,6 @@ public Statement getStatement() {
@Override
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
FireboltDataType dataType = resultSetMetaData.getColumn(columnIndex).getType().getDataType();
BaseType columnType = dataType.getBaseType();
Map<String, Class<?>> caseInsensitiveMap = new TreeMap<>(CASE_INSENSITIVE_ORDER);
caseInsensitiveMap.putAll(map);
Class<?> type = getAllNames(dataType).map(caseInsensitiveMap::get).filter(Objects::nonNull).findFirst()
Expand All @@ -969,11 +968,7 @@ private Stream<String> getAllNames(FireboltDataType dataType) {
}

private String getJdbcType(FireboltDataType dataType) {
try {
return JDBCType.valueOf(dataType.getSqlType()).getName();
} catch (IllegalArgumentException e) {
return null;
}
return JDBCType.valueOf(dataType.getSqlType()).getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,7 @@ void shouldGetDouble() throws SQLException {
assertEquals(1.23, resultSet.getDouble(3));

assertEquals(1.23456789012, resultSet.getObject(4, Double.class));
assertEquals(1.23456789012, (double)resultSet.getObject(4, Map.of("double precision", Double.class)), 0.01);
assertEquals(new BigDecimal("1.23456789012"), resultSet.getBigDecimal(4));

assertEquals(1231232.123459999990457054844258706536, resultSet.getObject(5, Double.class), 0.01);
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/com/firebolt/jdbc/type/FireboltDataTypeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.firebolt.jdbc.type;


import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

import java.sql.JDBCType;

import static org.junit.jupiter.api.Assertions.assertNotNull;

class FireboltDataTypeTest {
/**
* This test validates that {@link FireboltDataType#getSqlType()} return standard type defined in {@link java.sql.Types} and {@link JDBCType}.
* @param type - the type
*/
@ParameterizedTest
@EnumSource(FireboltDataType.class)
void sqlType(FireboltDataType type) {
// assert here is just to satisfy static code analysis. valueOf() either succeeds or throws IllegalArgumentException
assertNotNull(JDBCType.valueOf(type.getSqlType()));
}
}

0 comments on commit 40d9d86

Please sign in to comment.