Skip to content

Commit

Permalink
Merge pull request #145 from datafuselabs/fix/prepare-setstring
Browse files Browse the repository at this point in the history
fix: setString when prepare select stmt
  • Loading branch information
hantmac authored Feb 5, 2024
2 parents 76fc64e + eda0be9 commit cd14317
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ public void setBigDecimal(int i, BigDecimal bigDecimal)
public void setString(int i, String s)
throws SQLException {
checkOpen();
if (originalSql.toLowerCase().contains("insert") ||
originalSql.toLowerCase().contains("replace") ||
originalSql.toLowerCase().contains("merge")) {
if (originalSql.toLowerCase().startsWith("insert") ||
originalSql.toLowerCase().startsWith("replace") ||
originalSql.toLowerCase().startsWith("merge")) {
batchInsertUtils.ifPresent(insertUtils -> insertUtils.setPlaceHolderValue(i, s));
} else {
batchInsertUtils.ifPresent(insertUtils -> insertUtils.setPlaceHolderValue(i, String.format("%s%s%s", "'", s, "'")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public void testAllPreparedStatement() throws SQLException {
System.out.println(result);
Assertions.assertEquals(2, result);
}
try (PreparedStatement statement = conn.prepareStatement("select * from test_prepare_statement where b = ?")) {
try (PreparedStatement statement = conn.prepareStatement("select a, regexp_replace(b, '\\d', '*') from test_prepare_statement where b = ?")) {
statement.setString(1, "c");
ResultSet r = statement.executeQuery();
while (r.next()) {
Expand Down

0 comments on commit cd14317

Please sign in to comment.