Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fetching varint values #59

Merged
merged 2 commits into from
May 23, 2024
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 @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/com/ing/data/cassandra/jdbc/ResultSetUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'";
Expand Down
Loading