JackieTien97 commented on code in PR #16734:
URL: https://github.com/apache/iotdb/pull/16734#discussion_r2517244762
##########
iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBPreparedStatement.java:
##########
@@ -909,19 +909,21 @@ public void setShort(int parameterIndex, short x) throws
SQLException {
@Override
public void setString(int parameterIndex, String x) {
- // if the sql is an insert statement and the value is not a string
literal, add single quotes
- // The table model only supports single quotes, the tree model sql both
single and double quotes
- if ("table".equalsIgnoreCase(getSqlDialect())
- || ((sql.trim().toUpperCase().startsWith("INSERT")
- && !((x.startsWith("'") && x.endsWith("'"))
- || ((x.startsWith("\"") && x.endsWith("\""))
- && "tree".equals(getSqlDialect())))))) {
- this.parameters.put(parameterIndex, "'" + x + "'");
+ if (x == null) {
+ this.parameters.put(parameterIndex, null);
} else {
- this.parameters.put(parameterIndex, x);
+ this.parameters.put(parameterIndex, "'" + escapeSingleQuotes(x) + "'");
}
}
+ private String escapeSingleQuotes(String value) {
+ if (value == null) {
+ return null;
Review Comment:
throw Exception? You've already do null check in caller.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]