Skip to content

Commit 1ec2714

Browse files
committed
fix: null value and add tests
1 parent 05c657b commit 1ec2714

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

databend-jdbc/src/main/java/com/databend/jdbc/AbstractDatabendResultSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private Object column(int index)
363363
}
364364
Object value = null;
365365
value = row.get().get(index - 1);
366-
if (value == null || "NULL".equals(value.toString())) {
366+
if (value == null) {
367367
wasNull.set(true);
368368
return null;
369369
} else {

databend-jdbc/src/test/java/com/databend/jdbc/TestBasicDriver.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public void setUp()
3535
c.createStatement().execute("create table test_basic_driver.table1(i int)");
3636
c.createStatement().execute("insert into test_basic_driver.table1 values(1)");
3737
c.createStatement().execute("create database test_basic_driver_2");
38-
c.createStatement().execute("create table test_basic_driver.table_with_null(a int,b varchar default null)");
39-
c.createStatement().execute("insert into test_basic_driver.table_with_null(a) values(1)");
38+
c.createStatement().execute("create table test_basic_driver.table_with_null(a int,b varchar default null, c varchar, d varchar)");
39+
c.createStatement().execute("insert into test_basic_driver.table_with_null(a,b,c,d) values(1,null,'null','NULL')");
4040

4141
// json data
4242
}
@@ -201,11 +201,13 @@ public void testWriteDouble() throws SQLException {
201201
public void testDefaultSelectNullValue() throws SQLException {
202202
try (Connection connection = Utils.createConnection()) {
203203
DatabendStatement statement = (DatabendStatement) connection.createStatement();
204-
statement.executeQuery("SELECT a,b from test_basic_driver.table_with_null");
204+
statement.executeQuery("SELECT a,b,c,d from test_basic_driver.table_with_null");
205205
ResultSet r = statement.getResultSet();
206206
r.next();
207207
Assert.assertEquals(r.getInt(1), 1);
208208
Assert.assertEquals(r.getObject(2), null);
209+
Assert.assertEquals(r.getObject(3), "null");
210+
Assert.assertEquals(r.getObject(4), "NULL");
209211
} catch (SQLException throwables) {
210212
throwables.printStackTrace();
211213
}

0 commit comments

Comments
 (0)