diff --git a/src/main/java/com/ing/data/cassandra/jdbc/CassandraMetadataResultSet.java b/src/main/java/com/ing/data/cassandra/jdbc/CassandraMetadataResultSet.java index 6a5c079..ed0845d 100644 --- a/src/main/java/com/ing/data/cassandra/jdbc/CassandraMetadataResultSet.java +++ b/src/main/java/com/ing/data/cassandra/jdbc/CassandraMetadataResultSet.java @@ -686,8 +686,9 @@ public Object getObject(final int columnIndex) throws SQLException { case ASCII: case TEXT: return this.currentRow.getString(columnIndex - 1); - case INT: case VARINT: + return this.currentRow.getVarint(columnIndex - 1); + case INT: return this.currentRow.getInt(columnIndex - 1); case SMALLINT: return this.currentRow.getShort(columnIndex - 1); @@ -734,8 +735,9 @@ public Object getObject(final String columnLabel) throws SQLException { case ASCII: case TEXT: return this.currentRow.getString(columnLabel); - case INT: case VARINT: + return this.currentRow.getVarint(columnLabel); + case INT: return this.currentRow.getInt(columnLabel); case SMALLINT: return this.currentRow.getShort(columnLabel); diff --git a/src/main/java/com/ing/data/cassandra/jdbc/CassandraResultSet.java b/src/main/java/com/ing/data/cassandra/jdbc/CassandraResultSet.java index 1926803..1b1aac6 100644 --- a/src/main/java/com/ing/data/cassandra/jdbc/CassandraResultSet.java +++ b/src/main/java/com/ing/data/cassandra/jdbc/CassandraResultSet.java @@ -977,8 +977,9 @@ public Object getObject(final int columnIndex) throws SQLException { case ASCII: case TEXT: return this.currentRow.getString(columnIndex - 1); - case INT: case VARINT: + return this.currentRow.getBigInteger(columnIndex - 1); + case INT: return this.currentRow.getInt(columnIndex - 1); case SMALLINT: return this.currentRow.getShort(columnIndex - 1); @@ -1113,8 +1114,9 @@ public Object getObject(final String columnLabel) throws SQLException { case ASCII: case TEXT: return this.currentRow.getString(columnLabel); - case INT: case VARINT: + return this.currentRow.getBigInteger(columnLabel); + case INT: return this.currentRow.getInt(columnLabel); case SMALLINT: return this.currentRow.getShort(columnLabel); diff --git a/src/test/java/com/ing/data/cassandra/jdbc/ResultSetUnitTest.java b/src/test/java/com/ing/data/cassandra/jdbc/ResultSetUnitTest.java index 2052ea4..66574fe 100644 --- a/src/test/java/com/ing/data/cassandra/jdbc/ResultSetUnitTest.java +++ b/src/test/java/com/ing/data/cassandra/jdbc/ResultSetUnitTest.java @@ -18,6 +18,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.sql.ResultSet; import java.sql.SQLSyntaxErrorException; @@ -130,6 +131,17 @@ void givenResultSetWithRows_whenGetAsciiStream_returnExpectedValue() throws Exce assertArrayEquals("testValueAscii".getBytes(StandardCharsets.US_ASCII), byteArray); } + @Test + void givenVarintValue_whenFetching_returnExpectedValue() throws Exception { + final String cql = "select (varint) 1 from system.local"; + final Statement statement = sqlConnection.createStatement(); + final ResultSet rs = statement.executeQuery(cql); + assertTrue(rs.next()); + Object result = rs.getObject(1); + assertNotNull(result); + assertEquals(BigInteger.valueOf(1), result); + } + @Test void givenResultSetWithRows_whenGetCharacterStream_returnExpectedValue() throws Exception { final String cql = "SELECT col_blob FROM tbl_test_blobs WHERE keyname = 'key1'";