JSqlParser: Error while parsing literals with backslash
Describe the bug Can’t properly parse the statement when
- Backslash is the last character of a literal;
- The literal is not the last value of a sequence.
To Reproduce Steps to reproduce the behavior:
- Example:
CCJSqlParserUtil.parseStatements("""INSERT INTO "a"."b"("c", "d", "e") VALUES ('c c\', 'dd', 'ee\')""")
(Kotlin) - Exception:
net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "dd" <S_IDENTIFIER>
at line 1, column 53.
Was expecting one of:
"&"
")"
","
"::"
"<<"
">>"
"COLLATE"
"["
"^"
"|"
- Note that
CCJSqlParserUtil.parseStatements("""INSERT INTO "a"."b"("c", "d", "e") VALUES ('c c', 'dd', 'ee\')""")
won’t trigger the exception.
Expected behavior
The literals 'c c\'
and 'dd'
should be properly parsed.
System
- Database: Oracle
- Kotlin Version: 1.4.21-release-IJ2020.2-1
- Java Version: 1.8
- JSqlParser version: 4.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 35 (20 by maintainers)
Commits related to this issue
- feat: Configurable backslash `\` escaping - Enables `\` as escape character in String Literals (beside SQL:2016 compliant `'`) - Default is OFF (since its not SQL:2016 compliant) - Activate per Parse... — committed to manticore-projects/JSqlParser by manticore-projects a year ago
- Assorted Fixes #5 (#1715) * refactor: Merge REPLACE into UPSERT fixes #1706 * feat: `DROP TEMPORARY TABLE ...` fixes #1712 * build: PMD compliance * ci: Merge master * feat: Configu... — committed to JSQLParser/JSqlParser by manticore-projects a year ago
Yes, this was exactly what I have suggested to the @wumpz. As kind of Pre-Processing and Post-Processing outside of the Parser itself.
On Mon, 2021-05-24 at 21:06 -0700, Xingcan Cui wrote: