Skip to content

Commit

Permalink
[CONJ-852] CmdInformationSingle.isDuplicateKeyUpdate() fails to detec…
Browse files Browse the repository at this point in the history
…t ON DUPLICATE KEY clause if there are newlines in query.

Solved by enabling DOTALL mode in regexp.
  • Loading branch information
maqroll authored and rusher committed Jan 29, 2021
1 parent 9eec426 commit 722556c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -137,7 +137,7 @@ public ResultSet getGeneratedKeys(Protocol protocol, String sql) {
}

private boolean isDuplicateKeyUpdate(String sql) {
return sql.matches("(?i).*ON\\s+DUPLICATE\\s+KEY\\s+UPDATE.*");
return sql.matches("(?s)(?i).*ON\\s+DUPLICATE\\s+KEY\\s+UPDATE.*");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/mariadb/jdbc/MultiTest.java
Expand Up @@ -1457,7 +1457,7 @@ public void shouldDuplicateKeyUpdateNotReturnExtraRows() throws Throwable {
}
try (PreparedStatement pstmt =
con.prepareStatement(
"INSERT INTO testMultiGeneratedKey (id, text) VALUES (?, ?) "
"INSERT INTO testMultiGeneratedKey (id, text) \nVALUES (?, ?) "
+ "ON DUPLICATE KEY UPDATE text = VALUES(text)",
Statement.RETURN_GENERATED_KEYS)) {
// Insert a row.
Expand Down

0 comments on commit 722556c

Please sign in to comment.