Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12
Parser Configuration
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The SQL Parser API ships with a variety of settings that govern its behaviour. These settings include:
-
parseAppendMissingTableReferences: Support Teradata style implicit joins when projected table references aren't listed explicitly inFROMclause. -
parseDateFormat: The date format that is applied automatically when parsing date formatting functions without an explicit format. -
parseDialect: The parser input dialect. This dialect is used to decide what vendor specific grammar should be applied in case of ambiguities that cannot be resolved from the context. -
parseIgnoreComments: Using this flag, the parser can ignore certain sections that would otherwise be executed by RDBMS. Everything between anparseIgnoreCommentStartand theparseIgnoreCommentStoptoken will be ignored. -
parseIgnoreCommentStart: The token that delimits the beginning of a section to be ignored by jOOQ. Ideally, this token is placed inside of a SQL comment. -
parseIgnoreCommentStop: The token that delimits the end of a section to be ignored by jOOQ. Ideally, this token is placed inside of a SQL comment. -
parseIgnoreCommercialOnlyFeatures: Ignore commercial only features when parsing, to avoid unnecessary exceptions. -
parseMetaDefaultExpressions: Specify whetherorg.jooq.Metaimplementations should attempt to parseDEFAULTexpressions, or leave them as raw SQL strings. -
parseNameCase: Specify the name case behaviour, depending on whether names are quoted or not. -
parseNamedParamPrefix: The prefix used for named parameters, defaulting to:, e.g. for:paramstyle names. -
parseRetainCommentsBetweenQueries: Whether comments in between statements fromParser.parse()are retained and parsed as ignored queries. Comments inside of statements (including procedural statements) currently aren't supported by jOOQ. -
parseSearchPath: The search path to look up unqualified identifiers to be used when usingparseWithMetaLookups. Most dialects support a single schema on their search path (theCURRENT_SCHEMA). PostgreSQL supports a'search_path', which allows for listing multiple schemata to use to look up unqualified tables, procedures, etc. in. -
parseSetCommands: Whether SET commands should be parsed or ignored. -
parseTimestampFormat: The timestamp format that is applied automatically when parsing timestamp formatting functions without an explicit format. -
parseUnsupportedSyntax: The parser can parse some syntax that jOOQ does not support. By default, such syntax is ignored. Use this flag if you want to fail in such cases. -
parseUnknownFunctions: The parser only parses "known" (to jOOQ) built in functions, and fails otherwise. This flag allows for parsing any built in function using a standardfunc_name(arg1, arg2, ...)syntax. -
parseWithMetaLookups: Whetherorg.jooq.Metashould be used to look up meta information such as schemas, tables, columns, column types, etc.
An example of using the parseIgnoreComments feature:
-- What you execute /* [jooq ignore start] */ CREATE SCHEMA s1; SET SCHEMA s1; /* [jooq ignore stop] */ /* [jooq ignore start] */ -- /* [jooq ignore stop] */ CREATE SCHEMA s2; /* [jooq ignore start] */ -- /* [jooq ignore stop] */ SET SCHEMA s2; CREATE TABLE t (i INTEGER);
-- What the jOOQ parser sees
/*
*/
/* */ CREATE SCHEMA s2;
/* */ SET SCHEMA s2;
CREATE TABLE t (i INTEGER);
Example configuration
Settings settings = new Settings()
.withParseDialect(SQLSERVER) // Defaults to DEFAULT
.withParseWithMetaLookups(THROW_ON_FAILURE) // Defaults to OFF
.withParseSearchPath(
new ParseSearchSchemata().withSchema("PUBLIC"),
new ParseSearchSchemata().withSchema("TEST"))
.withParseUnsupportedSyntax(FAIL) // Defaults to IGNORE
.withParseUnknownFunctions(IGNORE) // Defaults to FAIL
.withParseIgnoreComments(true) // Defaults to false
.withParseIgnoreCommentStart("<ignore>") // Defaults to "[jooq ignore start]"
.withParseIgnoreCommentStop("</ignore>") // Defaults to "[jooq ignore stop]"
In addition to the above settings, there is also a powerful parser listener SPI called the org.jooq.ParseListener.
Feedback
Do you have any feedback about this page? We'd love to hear it!