Skip to content

Commit

Permalink
PLAT-6829 Change driver to treat BIT as bytes
Browse files Browse the repository at this point in the history
Summary: Change driver to treat BIT as bytes

Test Plan: https://app.circleci.com/pipelines/github/memsql/S2-JDBC-Connector/334/workflows/cbd8eb88-0c9d-4584-ab4e-ab427f4bebd0/jobs/1601

Reviewers: amakarovych-ua, pmishchenko-ua

Reviewed By: pmishchenko-ua

Subscribers: adam, engineering-list

JIRA Issues: PLAT-6829

Differential Revision: https://grizzly.internal.memcompute.com/D65359
  • Loading branch information
oyeliseiev-ua committed Nov 7, 2023
1 parent 162d682 commit db0115a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public int getColumnType(Configuration conf) {
return isSigned() ? Types.TINYINT : Types.SMALLINT;
case BIT:
if (length == 1) {
return Types.BOOLEAN;
return Types.BIT;
}
return Types.VARBINARY;
case SMALLINT:
Expand Down Expand Up @@ -466,9 +466,6 @@ public Codec<?> getDefaultCodec(Configuration conf) {
}
return isSigned() ? ByteCodec.INSTANCE : ShortCodec.INSTANCE;
case BIT:
if (length == 1) {
return BooleanCodec.INSTANCE;
}
return BitSetCodec.INSTANCE;
case SMALLINT:
return isSigned() ? ShortCodec.INSTANCE : IntCodec.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void getObjectPrepare() throws SQLException {
}

public void getObject(ResultSet rs) throws SQLException {
assertEquals(false, rs.getObject(1));
assertEquals(BitSet.valueOf(new byte[] {(byte) 0}), rs.getObject(1));
assertFalse(rs.wasNull());
assertEquals(BitSet.valueOf(new byte[] {(byte) 1}), rs.getObject(2));
assertEquals(BitSet.valueOf(new byte[] {(byte) 1}), rs.getObject("t2alias"));
Expand Down Expand Up @@ -662,10 +662,10 @@ public void getMetaData() throws SQLException {
ResultSetMetaData meta = rs.getMetaData();
assertEquals("BIT", meta.getColumnTypeName(1));
assertEquals(sharedConn.getCatalog(), meta.getCatalogName(1));
assertEquals("java.lang.Boolean", meta.getColumnClassName(1));
assertEquals("java.util.BitSet", meta.getColumnClassName(1));
assertEquals("t1alias", meta.getColumnLabel(1));
assertEquals("t1", meta.getColumnName(1));
assertEquals(Types.BOOLEAN, meta.getColumnType(1));
assertEquals(Types.BIT, meta.getColumnType(1));
assertEquals(4, meta.getColumnCount());
assertEquals(1, meta.getPrecision(1));
assertEquals(0, meta.getScale(1));
Expand Down

0 comments on commit db0115a

Please sign in to comment.