diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java index 5e29a527e7..9e78d9ea24 100644 --- a/jOOQ/src/main/java/org/jooq/conf/Settings.java +++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java @@ -16,6 +16,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.jooq.SQLDialect; /** @@ -135,6 +136,9 @@ public class Settings @XmlElement(defaultValue = "LOG_DEBUG") @XmlSchemaType(name = "string") protected ExecuteWithoutWhere executeDeleteWithoutWhere = ExecuteWithoutWhere.LOG_DEBUG; + @XmlElement(type = String.class, defaultValue = "DEFAULT") + @XmlJavaTypeAdapter(SQLDialectAdapter.class) + protected SQLDialect parseDialect; @XmlElement(defaultValue = "IGNORE_ON_FAILURE") @XmlSchemaType(name = "string") protected ParseWithMetaLookups parseWithMetaLookups = ParseWithMetaLookups.IGNORE_ON_FAILURE; @@ -1239,6 +1243,30 @@ public class Settings this.executeDeleteWithoutWhere = value; } + /** + * [#7337] The input dialect that should be chosen to disambiguate ambiguous SQL syntax. + * + * @return + * possible object is + * {@link String } + * + */ + public SQLDialect getParseDialect() { + return parseDialect; + } + + /** + * Sets the value of the parseDialect property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setParseDialect(SQLDialect value) { + this.parseDialect = value; + } + /** * [#7163] Whether the parser should perform meta lookups in the Configuration's MetaProvider. * @@ -1526,6 +1554,11 @@ public class Settings return this; } + public Settings withParseDialect(SQLDialect value) { + setParseDialect(value); + return this; + } + public Settings withParseWithMetaLookups(ParseWithMetaLookups value) { setParseWithMetaLookups(value); return this; @@ -1759,6 +1792,11 @@ public class Settings sb.append(executeDeleteWithoutWhere); sb.append(""); } + if (parseDialect!= null) { + sb.append(""); + sb.append(parseDialect); + sb.append(""); + } if (parseWithMetaLookups!= null) { sb.append(""); sb.append(parseWithMetaLookups); @@ -2176,6 +2214,15 @@ public class Settings return false; } } + if (parseDialect == null) { + if (other.parseDialect!= null) { + return false; + } + } else { + if (!parseDialect.equals(other.parseDialect)) { + return false; + } + } if (parseWithMetaLookups == null) { if (other.parseWithMetaLookups!= null) { return false; @@ -2253,6 +2300,7 @@ public class Settings result = ((prime*result)+((emulateOnDuplicateKeyUpdateOnPrimaryKeyOnly == null)? 0 :emulateOnDuplicateKeyUpdateOnPrimaryKeyOnly.hashCode())); result = ((prime*result)+((executeUpdateWithoutWhere == null)? 0 :executeUpdateWithoutWhere.hashCode())); result = ((prime*result)+((executeDeleteWithoutWhere == null)? 0 :executeDeleteWithoutWhere.hashCode())); + result = ((prime*result)+((parseDialect == null)? 0 :parseDialect.hashCode())); result = ((prime*result)+((parseWithMetaLookups == null)? 0 :parseWithMetaLookups.hashCode())); result = ((prime*result)+((parseUnsupportedSyntax == null)? 0 :parseUnsupportedSyntax.hashCode())); result = ((prime*result)+((parseUnknownFunctions == null)? 0 :parseUnknownFunctions.hashCode())); diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index b1f84c6189..2f53f7e90a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -39,6 +39,7 @@ package org.jooq.impl; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; +// ... import static org.jooq.conf.ParseWithMetaLookups.IGNORE_ON_FAILURE; import static org.jooq.conf.ParseWithMetaLookups.THROW_ON_FAILURE; import static org.jooq.impl.DSL.abs; @@ -392,6 +393,7 @@ import org.jooq.Row; import org.jooq.Row2; import org.jooq.RowN; import org.jooq.SQL; +import org.jooq.SQLDialect; import org.jooq.Schema; import org.jooq.Select; import org.jooq.SelectFieldOrAsterisk; @@ -4150,13 +4152,25 @@ final class ParserImpl implements Parser { result.add(qa); } else { - Field field = parseField(ctx); Name alias = null; + Field field = null; - if (parseKeywordIf(ctx, "AS")) - alias = parseIdentifier(ctx, true); - else if (!peekKeyword(ctx, KEYWORDS_IN_SELECT)) - alias = parseIdentifierIf(ctx, true); + + + + + + + + + if (field == null) { + field = parseField(ctx); + + if (parseKeywordIf(ctx, "AS")) + alias = parseIdentifier(ctx, true); + else if (!peekKeyword(ctx, KEYWORDS_IN_SELECT)) + alias = parseIdentifierIf(ctx, true); + } result.add(alias == null ? field : field.as(alias)); } @@ -9109,6 +9123,19 @@ final class ParserContext { this.bindings = bindings; } + SQLDialect dialect() { + SQLDialect result = dsl.configuration().settings().getParseDialect(); + + if (result == null) + result = SQLDialect.DEFAULT; + + return result; + } + + SQLDialect family() { + return dialect().family(); + } + boolean requireProEdition() { if (!PRO_EDITION) throw exception("Feature only supported in pro edition"); diff --git a/jOOQ/src/main/resources/xjb/runtime/binding.xjb b/jOOQ/src/main/resources/xjb/runtime/binding.xjb index 3edbcf7564..056279e97f 100644 --- a/jOOQ/src/main/resources/xjb/runtime/binding.xjb +++ b/jOOQ/src/main/resources/xjb/runtime/binding.xjb @@ -25,6 +25,11 @@ + + + + + org.jooq.conf.SettingsBase diff --git a/jOOQ/src/main/resources/xsd/jooq-runtime-3.12.0.xsd b/jOOQ/src/main/resources/xsd/jooq-runtime-3.12.0.xsd index 908fc938b4..0c286030dd 100644 --- a/jOOQ/src/main/resources/xsd/jooq-runtime-3.12.0.xsd +++ b/jOOQ/src/main/resources/xsd/jooq-runtime-3.12.0.xsd @@ -246,6 +246,10 @@ jOOQ queries, for which no specific fetchSize value was specified.]]> + + + +