AI disclosure: this issue was prepared with AI coding agents, reviewed and revised line by line by me.
Grammar or Syntax Description
Not a single grammar production, but the switch layer below it. JSqlParser now has three lexer-level switches, each added when one lexeme carries different meanings in two dialects:
Every lexeme conflict settled the same way adds one more switch, and every user of a dialect then has to know and wire the full set by hand:
CCJSqlParserUtil.parse(sql, parser -> parser.withBackslashEscapeCharacter(true)
.withHashLineComments(true));
Proposal: a preset layer so one call selects the dialect's full switch set. Prototyping found the parser already owns a narrow Dialect enum (ORACLE, EXASOL) behind withDialect(Dialect) for grammar gating, so extending that enum keeps a single entry point:
CCJSqlParserUtil.parse(sql, parser -> parser.withDialect(Dialect.MYSQL));
Pure data mapping, no mechanism changes: individual switches keep working and override the preset.
SQL Example
One statement, MySQL reading, today vs proposed:
-- MySQL: `col` is a quoted identifier, 'x\'yz' keeps the escaped quote, 42#24 is 42 plus a line comment
SELECT `col` FROM t WHERE a = 'x\'yz' AND b = 42#24
today: two switches wired manually per parse call (backticks already parse by default, brackets are not MySQL syntax); proposed: withDialect(Dialect.MYSQL) once.
Additional context
AI disclosure: this issue was prepared with AI coding agents, reviewed and revised line by line by me.
Grammar or Syntax Description
Not a single grammar production, but the switch layer below it. JSqlParser now has three lexer-level switches, each added when one lexeme carries different meanings in two dialects:
Feature.allowSquareBracketQuotation(v3.0, should bracket quotation (like sqlserver supports it) be removed to be able to support array constructs #677: SQL Server quoting vs Postgres arrays)Feature.allowBackslashEscapeCharacter(v4.6: backslash escapes)Feature.allowHashLineComments(feat(parser): support MySQL # line comments behind allowHashLineComments #2508: MySQL#line comments vs the Postgres#operator from fix(parser): support PostgreSQL # binary operator (bitwise XOR / geometric intersection) #2507)Every lexeme conflict settled the same way adds one more switch, and every user of a dialect then has to know and wire the full set by hand:
Proposal: a preset layer so one call selects the dialect's full switch set. Prototyping found the parser already owns a narrow
Dialectenum (ORACLE,EXASOL) behindwithDialect(Dialect)for grammar gating, so extending that enum keeps a single entry point:Pure data mapping, no mechanism changes: individual switches keep working and override the preset.
SQL Example
One statement, MySQL reading, today vs proposed:
today: two switches wired manually per parse call (backticks already parse by default, brackets are not MySQL syntax); proposed:
withDialect(Dialect.MYSQL)once.Additional context
177dbd7.#).Dialectenum or beside the validation-sideDatabaseType, and whether the validation feature sets and the parse-time switches should share one table.Dialectenum); the shared validation table stays open as a follow-up.