Description
Actual Behavior
I want to escape the backslash character in an insert statement at the end of a string value. To do this I use the following statement:
String insert = "INSERT INTO my_table (my_column_1, my_column_2) VALUES ('my_value_1\\', 'my_value_2')";
But when I want to parse it, it throws an exception:
CCJSqlParserUtil.parse(insert);
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "my_value_2" <S_IDENTIFIER>
at line 1, column 73.
Was expecting one of:
"&"
")"
","
"::"
"<<"
">>"
"COLLATE"
"^"
"|"
at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:20951)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:20798)
at net.sf.jsqlparser.parser.CCJSqlParser.Insert(CCJSqlParser.java:1537)
at net.sf.jsqlparser.parser.CCJSqlParser.SingleStatement(CCJSqlParser.java:132)
at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:70)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:41)
... 1 more
It works fine in the following cases:
-
If the backslash is not at the end of the string, for example:
"INSERT INTO my_table (my_column_1, my_column_2) VALUES ('my_value\\_1', 'my_value_2')";
-
If I only want to insert a single column:
INSERT INTO my_table (my_column_1) VALUES ('my_value_1\\')
-
With SELECT, UPDATE, and MERGE instructions.
Specifications
- Version: 2.1
- Platform:
- Subsystem: