fix: support SQL-standard doubled quotes in string literals by eaallen · Pull Request #65 · JavaScriptor/js-sql-parser
Repository navigation
fix: support SQL-standard doubled quotes in string literals - #65
Open
eaallen wants to merge 1 commit into JavaScriptor:master from eaallen:fix/sql-standard-escaped-quotes
Open
fix: support SQL-standard doubled quotes in string literals #65 eaallen wants to merge 1 commit into JavaScriptor:master from eaallen:fix/sql-standard-escaped-quotes
Conversation
eaallen commented Jul 21, 2026 · edited Loading
Copy link Copy Markdown
Summary
- The STRING lexer rules only accepted backslash escapes (
\'/\"), so MySQL/SQL-standard doubled quotes like'O''Hare'were tokenized as two strings and failed to parse. - Update the lexer to also accept
''/""inside quoted literals, matching MySQL 5.7 string literals . - Add a regression test covering doubled single/double quotes, empty strings, and existing backslash escapes.
Test plan
-
npm test-- all 37 tests pass locally - Maintainer: rebuild (
npm run build) and cut a release so npm consumers pick up the fix
Made with Cursor
fix: support SQL-standard doubled quotes in string literals
dfa3528
MySQL/SQL allow escaping a quote inside a string by doubling it (e.g. 'O''Hare'). The lexer only recognized backslash escapes, so these literals were split into multiple STRING tokens and failed to parse. Update the STRING lexer rules to accept '' and "" inside quoted strings, matching https://dev.mysql.com/doc/refman/5.7/en/string-literals.html Co-authored-by: Cursor <cursoragent@cursor.com>
eaallen commented Jul 27, 2026
Copy link Copy Markdown
Author
|
Ahoy, this seems like a great fix to this lib! I already had to fork this project so my project could be fixed, so I am not in a rush. But this does seem like a genuine gap this pr fixes. |