Skip to content

Commit

Permalink
(#350) Fix insert null value on nullable number columns
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed May 27, 2021
1 parent 70a7f3b commit e4ade10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public Object deserializeTextQuoted(SQLLexer lexer) throws SQLException {

@Override
public void serializeBinary(Object data, BinarySerializer serializer) throws SQLException, IOException {
if (data == null) {
this.nestedDataType.serializeBinary(this.nestedDataType.defaultValue(), serializer);
}
this.nestedDataType.serializeBinary(data, serializer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ public void successfullyInsertData() throws Exception {
"day2 Date, " +
"time DateTime, " +
"time2 DateTime, " +
"flag Boolean" +
"flag Boolean, " +
"may_null Nullable(Int64)" +
")ENGINE = Log");

PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO test VALUES(?, ?, ?, ?, ?, ?)");
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO test VALUES(?, ?, ?, ?, ?, ?, ?)");

// 2018-07-01 19:00:00 GMT
// 2018-07-02 03:00:00 Asia/Shanghai
Expand All @@ -235,6 +236,7 @@ public void successfullyInsertData() throws Exception {
preparedStatement.setTimestamp(4, new Timestamp(time * 1000));
preparedStatement.setObject(5, LocalDateTime.of(2018, 7, 2, 3, 0, 0, 0));
preparedStatement.setBoolean(6, true);
preparedStatement.setObject(7, null);
assertEquals(1, preparedStatement.executeUpdate());
});
}
Expand Down

0 comments on commit e4ade10

Please sign in to comment.