diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java index c6746329b7..2fec5d9957 100644 --- a/jOOQ/src/main/java/org/jooq/conf/Settings.java +++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java @@ -103,6 +103,8 @@ public class Settings protected Boolean renderGroupConcatMaxLenSessionVariable = true; @XmlElement(defaultValue = "false") protected Boolean renderParenthesisAroundSetOperationQueries = false; + @XmlElement(defaultValue = "true") + protected Boolean renderVariablesInDerivedTablesForEmulations = true; @XmlElement(defaultValue = ".") protected String namePathSeparator = "."; @XmlElement(defaultValue = "false") @@ -1036,6 +1038,32 @@ public class Settings this.renderParenthesisAroundSetOperationQueries = value; } + /** + * Whether emulations that require repeating expressions should render variables for those expressions in derived tables. + *
+ * For details, see https://github.com/jOOQ/jOOQ/issues/14065. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isRenderVariablesInDerivedTablesForEmulations() { + return renderVariablesInDerivedTablesForEmulations; + } + + /** + * Sets the value of the renderVariablesInDerivedTablesForEmulations property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setRenderVariablesInDerivedTablesForEmulations(Boolean value) { + this.renderVariablesInDerivedTablesForEmulations = value; + } + /** * The character(s) to be used as a separator in paths encoded in a {@link Name} *
@@ -4463,6 +4491,11 @@ public class Settings return this; } + public Settings withRenderVariablesInDerivedTablesForEmulations(Boolean value) { + setRenderVariablesInDerivedTablesForEmulations(value); + return this; + } + /** * The character(s) to be used as a separator in paths encoded in a {@link Name} *
@@ -5525,6 +5558,7 @@ public class Settings
builder.append("renderOutputForSQLServerReturningClause", renderOutputForSQLServerReturningClause);
builder.append("renderGroupConcatMaxLenSessionVariable", renderGroupConcatMaxLenSessionVariable);
builder.append("renderParenthesisAroundSetOperationQueries", renderParenthesisAroundSetOperationQueries);
+ builder.append("renderVariablesInDerivedTablesForEmulations", renderVariablesInDerivedTablesForEmulations);
builder.append("namePathSeparator", namePathSeparator);
builder.append("bindOffsetDateTimeType", bindOffsetDateTimeType);
builder.append("bindOffsetTimeType", bindOffsetTimeType);
@@ -5925,6 +5959,15 @@ public class Settings
return false;
}
}
+ if (renderVariablesInDerivedTablesForEmulations == null) {
+ if (other.renderVariablesInDerivedTablesForEmulations!= null) {
+ return false;
+ }
+ } else {
+ if (!renderVariablesInDerivedTablesForEmulations.equals(other.renderVariablesInDerivedTablesForEmulations)) {
+ return false;
+ }
+ }
if (namePathSeparator == null) {
if (other.namePathSeparator!= null) {
return false;
@@ -7183,6 +7226,7 @@ public class Settings
result = ((prime*result)+((renderOutputForSQLServerReturningClause == null)? 0 :renderOutputForSQLServerReturningClause.hashCode()));
result = ((prime*result)+((renderGroupConcatMaxLenSessionVariable == null)? 0 :renderGroupConcatMaxLenSessionVariable.hashCode()));
result = ((prime*result)+((renderParenthesisAroundSetOperationQueries == null)? 0 :renderParenthesisAroundSetOperationQueries.hashCode()));
+ result = ((prime*result)+((renderVariablesInDerivedTablesForEmulations == null)? 0 :renderVariablesInDerivedTablesForEmulations.hashCode()));
result = ((prime*result)+((namePathSeparator == null)? 0 :namePathSeparator.hashCode()));
result = ((prime*result)+((bindOffsetDateTimeType == null)? 0 :bindOffsetDateTimeType.hashCode()));
result = ((prime*result)+((bindOffsetTimeType == null)? 0 :bindOffsetTimeType.hashCode()));
diff --git a/jOOQ/src/main/java/org/jooq/impl/Tools.java b/jOOQ/src/main/java/org/jooq/impl/Tools.java
index 2470630d1f..7369b81027 100644
--- a/jOOQ/src/main/java/org/jooq/impl/Tools.java
+++ b/jOOQ/src/main/java/org/jooq/impl/Tools.java
@@ -123,6 +123,7 @@ import static org.jooq.impl.DSL.unquotedName;
import static org.jooq.impl.DSL.val;
import static org.jooq.impl.DefaultExecuteContext.localConnection;
import static org.jooq.impl.DefaultParseContext.SUPPORTS_HASH_COMMENT_SYNTAX;
+import static org.jooq.impl.DerivedTable.NO_SUPPORT_CORRELATED_DERIVED_TABLE;
import static org.jooq.impl.Identifiers.QUOTES;
import static org.jooq.impl.Identifiers.QUOTE_END_DELIMITER;
import static org.jooq.impl.Identifiers.QUOTE_END_DELIMITER_ESCAPED;
@@ -279,6 +280,9 @@ import org.jooq.FieldOrRow;
import org.jooq.FieldOrRowOrSelect;
import org.jooq.Fields;
import org.jooq.ForeignKey;
+import org.jooq.Function1;
+import org.jooq.Function2;
+import org.jooq.Function3;
import org.jooq.Generator;
import org.jooq.JSON;
import org.jooq.JSONB;
@@ -308,6 +312,7 @@ import org.jooq.Scope;
import org.jooq.ContextConverter;
import org.jooq.Select;
import org.jooq.SelectFieldOrAsterisk;
+import org.jooq.SelectJoinStep;
import org.jooq.SortField;
import org.jooq.Source;
import org.jooq.Table;
@@ -7161,4 +7166,57 @@ final class Tools {
static final ConverterContext converterContext(Configuration configuration) {
return new DefaultConverterContext(configuration(configuration));
}
+
+ /**
+ * Wrap an expression in a derived table to allow for simplifying
+ * referencing it.
+ */
+ static final true the queries combined with set oper
For details, see https://github.com/jOOQ/jOOQ/issues/3676 and https://github.com/jOOQ/jOOQ/issues/9751.]]>
+