fix: add SQL-standard '' single quote escape in Cypher string literals#729
Open
chiangchenghsin-hash wants to merge 1 commit into
Open
fix: add SQL-standard '' single quote escape in Cypher string literals#729chiangchenghsin-hash wants to merge 1 commit into
chiangchenghsin-hash wants to merge 1 commit into
Conversation
Support the SQL-92 standard two-single-quotes escape sequence ('')
within Cypher string literals, complementing the existing backslash
escape. Fixes parser failures on strings like 'It''s a test'.
Changes:
- transformer.cpp: handle '' → ' in transformStringLiteral()
- Cypher.g4: add '\\'\\'' alternative to StringLiteral grammar rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds SQL-92 standard two-single-quotes (
'') escape support within Cypher single-quoted string literals, complementing the existing backslash (\') escape.Problem
Cypher uses backslash escapes for strings (
'It\'s a test'), which differs from the SQL standard ('It''s a test'). This causes parser exceptions when users write SQL-style escaped strings — a common pitfall for those coming from SQL backgrounds.Fix
Two changes:
src/parser/transformer.cpp: IntransformStringLiteral(), add handling for consecutive single quotes ('') before the fallbackelsebranch — translates''to'.src/antlr4/Cypher.g4: Add'\'\''as an alternative within the single-quotedStringLiteralrule, so the ANTLR lexer recognizes''as a valid token sequence inside a string literal.Verification
"It's working"(double-quote workaround for single quotes) — ✅ already works'It''s a test'(SQL-style escape) — ✅ fixed (was Parser exception before)