Skip to content

Commit

Permalink
Merge pull request #109 from raymondchen-byte/main
Browse files Browse the repository at this point in the history
support decimal type and support delete varchar field
  • Loading branch information
hantmac authored Dec 7, 2023
2 parents 4d54f4f + b1d09df commit 0d2ab46
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ private static int getType(DatabendRawType type) {
return java.sql.Types.TIMESTAMP;
case DatabendTypes.ARRAY:
return java.sql.Types.ARRAY;
case DatabendTypes.DECIMAL:
return java.sql.Types.DECIMAL;
default:
return Types.JAVA_OBJECT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,11 @@ public void setBigDecimal(int i, BigDecimal bigDecimal)
public void setString(int i, String s)
throws SQLException {
checkOpen();
batchInsertUtils.ifPresent(insertUtils -> insertUtils.setPlaceHolderValue(i, s));
if (originalSql.toLowerCase().contains("delete from")) {
batchInsertUtils.ifPresent(insertUtils -> insertUtils.setPlaceHolderValue(i, String.format("%s%s%s", "'", s, "'")));
} else {
batchInsertUtils.ifPresent(insertUtils -> insertUtils.setPlaceHolderValue(i, s));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ public void testAllPreparedStatement() throws SQLException {
int result = statement.executeUpdate();
System.out.println(result);
}

String deleteSQLVarchar = "delete from test_prepare_statement where b = ?";
try (PreparedStatement statement = conn.prepareStatement(deleteSQLVarchar)) {
statement.setString(1, "1");
int result = statement.executeUpdate();
System.out.println(result);
}

ResultSet r3 = conn.createStatement().executeQuery("select * from test_prepare_statement");
Assert.assertEquals(0, r3.getRow());
while (r3.next()) {
Expand Down

0 comments on commit 0d2ab46

Please sign in to comment.