@@ -43,6 +43,7 @@ public class StatementImpl implements Statement, JdbcV2Wrapper {
4343 private boolean closeOnCompletion ;
4444 private boolean resultSetAutoClose ;
4545 private int maxFieldSize ;
46+ private boolean escapeProcessingEnabled ;
4647
4748 // settings local to a statement
4849 protected QuerySettings localSettings ;
@@ -56,6 +57,7 @@ public StatementImpl(ConnectionImpl connection) throws SQLException {
5657 this .localSettings = QuerySettings .merge (connection .getDefaultQuerySettings (), new QuerySettings ());
5758 this .resultSets = new ConcurrentLinkedQueue <>();
5859 this .resultSetAutoClose = connection .getJdbcConfig ().isSet (DriverProperties .RESULTSET_AUTO_CLOSE );
60+ this .escapeProcessingEnabled = true ;
5961 }
6062
6163 protected void ensureOpen () throws SQLException {
@@ -65,24 +67,26 @@ protected void ensureOpen() throws SQLException {
6567 }
6668
6769
68- protected static String parseJdbcEscapeSyntax (String sql ) {
70+ private String parseJdbcEscapeSyntax (String sql ) {
6971 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')" );
7275
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')" );
7578
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" );
7881
79- // Handle outer escape syntax
80- //sql = sql.replaceAll("\\{escape '([^']*)'\\}", "'$1'");
82+ // Handle outer escape syntax
83+ //sql = sql.replaceAll("\\{escape '([^']*)'\\}", "'$1'");
8184
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 );
8690 return sql ;
8791 }
8892
@@ -253,7 +257,7 @@ public void setMaxRows(int max) throws SQLException {
253257 @ Override
254258 public void setEscapeProcessing (boolean enable ) throws SQLException {
255259 ensureOpen ();
256- //TODO: Should we support this?
260+ this . escapeProcessingEnabled = enable ;
257261 }
258262
259263 @ Override
0 commit comments