Skip to content

Commit 40d423c

Browse files
committed
docs(site): document the Dialect preset in the parser features section
Per review on #2511: the usage page's parser features section gets the withDialect preset paragraph and example, which also covers withHashLineComments (part of the MySQL and MariaDB presets, previously undocumented).
1 parent d58aee4 commit 40d423c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/site/sphinx/usage.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,16 @@ Additionally there are Features to control the Parser's effort at the cost of th
317317
sqlStr
318318
, parser -> parser
319319
.withBackslashEscapeCharacter(true)
320-
);
320+
);
321+
322+
Instead of turning the individual Parser Features on one by one, a ``Dialect`` preset selects the features of that database dialect: ``withDialect(Dialect.MYSQL)`` turns on ``withBackslashEscapeCharacter`` and ``withHashLineComments`` (both MySQL and MariaDB syntax), ``withDialect(Dialect.SQLSERVER)`` turns on ``withSquareBracketQuotation``. Features set explicitly after the dialect preset win over the preset.
323+
324+
.. code-block:: java
325+
326+
// Select the Database Dialect: turns on that dialect's parser features
327+
sqlStr="SELECT `col` FROM t WHERE a = 'x\\'yz' AND b = 42#24";
328+
Statement stmt3 = CCJSqlParserUtil.parse(
329+
sqlStr
330+
, parser -> parser
331+
.withDialect(Dialect.MYSQL)
332+
);

0 commit comments

Comments
 (0)