feat(parser): support double quoted string literals behind allowDoubleQuotedStrings - #2513
Merged
manticore-projects merged 1 commit intoAug 26, 2026
Merged
Conversation
…eQuotedStrings One lexeme, two readings: ANSI/Postgres/Oracle and SQL Server quote identifiers with double quotes, while BigQuery, Spark/Databricks and MySQL default sql_mode read them as string literals. The switch rewrites the token kind in the S_QUOTED_IDENTIFIER action (the square bracket machinery below), StringValue keeps the double quote on round-trip via its quoteStr. MYSQL and MARIADB presets carry the switch. Implements item 1 of JSQLParser#2512.
Contributor
|
Great! Thank you for your time and effort! |
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.
AI disclosure: this change was prepared with AI coding agents, reviewed and revised line by line by me.
What
Double quoted string literals behind a feature switch, item 1 of #2512:
Why
One lexeme, two readings, inventoried across the dialects JSqlParser models and the popular engines, every row verified against the vendor docs:
"..."reads asSQLite is the documented exception: identifier by the standard, with its double-quoted-string "misfeature" fallback when nothing matches, which a parser should not replicate. Master always produced the identifier reading, so the string side silently got a Column where their dialect has a string value.
How
The
S_QUOTED_IDENTIFIERtoken action rewrites the token kind to the string literal token when the feature is on, the same place the square bracket quotation machinery lives (#677 style, no grammar changes).StringValuestrips double quotes and keeps them for round-trip through its existingquoteStr(the$$path already worked this way); the publicStringValue(String)constructor accordingly strips a double-quoted argument the way it always stripped single-quoted ones. Backticks and brackets are untouched (first-character guard).The
MYSQLandMARIADBpresets carry the switch (default sql_mode reading; under ANSI_QUOTES MySQL flips back to identifiers, so preset users wanting that reading keep the explicit switch off).Disclosed leniency: in table positions a
"..."token follows the existing string-as-table branch (FROM 'file.csv'), the same leniency single quotes already have; MySQL itself errors there.Testing
CCJSqlParserUtilTest:testDoubleQuotedStringsFeature(off = Column unchanged, on = StringValue with value and round-trip, empty string, doubled quotes, the string-as-table leniency),testDoubleQuotedStringsPreset(MYSQL/MARIADB on, SQLSERVER off). All verified failing with the token rewrite removed, with the StringValue branch removed, and with MYSQL missing the preset feature; full suite green.Performance
gradle jmh,JSQLParserBenchmark.parseSQLStatementsonperformance.sql,version=latest, 10 forks × 10 iterations (100 samples) on a 32-core host, interleaved master/branch:94c4508Same-window deltas are +0.6% and +0.3% with overlapping CIs, and the drift between the two master runs (3.754 -> 3.795) is larger than the master/branch delta: no regression. The residual is the one added
getAsBooleanin theS_QUOTED_IDENTIFIERaction, paid per quoted identifier token only.Implements item 1 of #2512.