@@ -43,6 +43,7 @@ public class StatementImpl implements Statement, JdbcV2Wrapper {
43
43
private boolean closeOnCompletion ;
44
44
private boolean resultSetAutoClose ;
45
45
private int maxFieldSize ;
46
+ private boolean escapeProcessingEnabled ;
46
47
47
48
// settings local to a statement
48
49
protected QuerySettings localSettings ;
@@ -56,6 +57,7 @@ public StatementImpl(ConnectionImpl connection) throws SQLException {
56
57
this .localSettings = QuerySettings .merge (connection .getDefaultQuerySettings (), new QuerySettings ());
57
58
this .resultSets = new ConcurrentLinkedQueue <>();
58
59
this .resultSetAutoClose = connection .getJdbcConfig ().isSet (DriverProperties .RESULTSET_AUTO_CLOSE );
60
+ this .escapeProcessingEnabled = true ;
59
61
}
60
62
61
63
protected void ensureOpen () throws SQLException {
@@ -65,24 +67,26 @@ protected void ensureOpen() throws SQLException {
65
67
}
66
68
67
69
68
- protected static String parseJdbcEscapeSyntax (String sql ) {
70
+ private String parseJdbcEscapeSyntax (String sql ) {
69
71
LOG .trace ("Original SQL: {}" , sql );
70
- // Replace {d 'YYYY-MM-DD'} with corresponding SQL date format
71
- sql = sql .replaceAll ("\\ {d '([^']*)'\\ }" , "toDate('$1')" );
72
+ if (escapeProcessingEnabled ) {
73
+ // Replace {d 'YYYY-MM-DD'} with corresponding SQL date format
74
+ sql = sql .replaceAll ("\\ {d '([^']*)'\\ }" , "toDate('$1')" );
72
75
73
- // Replace {ts 'YYYY-MM-DD HH:mm:ss'} with corresponding SQL timestamp format
74
- sql = sql .replaceAll ("\\ {ts '([^']*)'\\ }" , "timestamp('$1')" );
76
+ // Replace {ts 'YYYY-MM-DD HH:mm:ss'} with corresponding SQL timestamp format
77
+ sql = sql .replaceAll ("\\ {ts '([^']*)'\\ }" , "timestamp('$1')" );
75
78
76
- // Replace function escape syntax {fn <function>} (e.g., {fn UCASE(name)})
77
- sql = sql .replaceAll ("\\ {fn ([^\\ }]*)\\ }" , "$1" );
79
+ // Replace function escape syntax {fn <function>} (e.g., {fn UCASE(name)})
80
+ sql = sql .replaceAll ("\\ {fn ([^\\ }]*)\\ }" , "$1" );
78
81
79
- // Handle outer escape syntax
80
- //sql = sql.replaceAll("\\{escape '([^']*)'\\}", "'$1'");
82
+ // Handle outer escape syntax
83
+ //sql = sql.replaceAll("\\{escape '([^']*)'\\}", "'$1'");
81
84
82
- // Clean new empty lines in sql
83
- sql = sql .replaceAll ("(?m)^\\ s*$\\ n?" , "" );
84
- // Add more replacements as needed for other JDBC escape sequences
85
- LOG .trace ("Parsed SQL: {}" , sql );
85
+ // Clean new empty lines in sql
86
+ sql = sql .replaceAll ("(?m)^\\ s*$\\ n?" , "" );
87
+ // Add more replacements as needed for other JDBC escape sequences
88
+ }
89
+ LOG .trace ("Escaped SQL: {}" , sql );
86
90
return sql ;
87
91
}
88
92
@@ -253,7 +257,7 @@ public void setMaxRows(int max) throws SQLException {
253
257
@ Override
254
258
public void setEscapeProcessing (boolean enable ) throws SQLException {
255
259
ensureOpen ();
256
- //TODO: Should we support this?
260
+ this . escapeProcessingEnabled = enable ;
257
261
}
258
262
259
263
@ Override
0 commit comments