Skip to content

Commit

Permalink
delete support varchar field
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondchen-byte committed Dec 6, 2023
1 parent ee52c6f commit b1d09df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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 b1d09df

Please sign in to comment.