Skip to content

Commit 42e5903

Browse files
authored
fix: Types.BOOLEAN and Types.BIT should have identical behaviour for nullability (#920)
* Types.BOOLEAN and Types.BIT should have identical behaviour for nullability. In master, BOOLEAN is nullable but BIT will throw IllegalArgumentException if an attempt is made to set a null value. * fix: Types.BOOLEAN and Types.BIT should have identical behaviour for nullability. In master, BOOLEAN is nullable but BIT will throw IllegalArgumentException if an attempt is made to set a null value.
1 parent f13ad39 commit 42e5903

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/main/java/com/google/cloud/spanner/jdbc/JdbcParameterStore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ private Builder setNullValue(ValueBinder<Builder> binder, Integer sqlType) {
858858
return binder.to((ByteArray) null);
859859
case Types.BLOB:
860860
return binder.to((ByteArray) null);
861+
case Types.BIT:
861862
case Types.BOOLEAN:
862863
return binder.to((Boolean) null);
863864
case Types.CHAR:

src/test/java/com/google/cloud/spanner/jdbc/JdbcParameterStoreTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.junit.Assert.assertArrayEquals;
2020
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertNull;
2122
import static org.junit.Assert.assertTrue;
2223
import static org.junit.Assert.fail;
2324
import static org.junit.Assume.assumeTrue;
@@ -379,6 +380,9 @@ public void testSetParameterWithType() throws SQLException, IOException {
379380
params.setParameter(1, BigDecimal.ZERO, type);
380381
assertEquals(BigDecimal.ZERO, params.getParameter(1));
381382
verifyParameter(params, Value.bool(false));
383+
params.setParameter(1, null, type);
384+
assertNull(params.getParameter(1));
385+
verifyParameter(params, Value.bool(null));
382386
}
383387

384388
// types that should lead to numeric

0 commit comments

Comments
 (0)