diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java
index 2fe5d1dab9..662220c74c 100644
--- a/jOOQ/src/main/java/org/jooq/conf/Settings.java
+++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java
@@ -191,6 +191,8 @@ public class Settings
@XmlElement(defaultValue = "true")
protected Boolean transformPatternsSimplifyCaseAbbreviation = true;
@XmlElement(defaultValue = "true")
+ protected Boolean transformPatternsFlattenCaseAbbreviation = true;
+ @XmlElement(defaultValue = "true")
protected Boolean transformPatternsTrivialCaseAbbreviation = true;
@XmlElement(defaultValue = "true")
protected Boolean transformPatternsTrivialPredicates = true;
@@ -2357,6 +2359,38 @@ public class Settings
this.transformPatternsSimplifyCaseAbbreviation = value;
}
+ /**
+ * Flatten nested CASE abbreviations such as NVL or CASE.
+ *
+ * Nested CASE abbreviations can be flattened, as such:
+ *
NVL(NVL(a, b), c) to COALESCE(a, b, c)COALESCE(a, ..., COALESCE(b, ..., c), ..., d) to COALESCE(a, …, b, …, c, ..., d)
+ * This feature is available in the commercial distribution only.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public Boolean isTransformPatternsFlattenCaseAbbreviation() {
+ return transformPatternsFlattenCaseAbbreviation;
+ }
+
+ /**
+ * Sets the value of the transformPatternsFlattenCaseAbbreviation property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setTransformPatternsFlattenCaseAbbreviation(Boolean value) {
+ this.transformPatternsFlattenCaseAbbreviation = value;
+ }
+
/**
* Transform trivial case abbreviations like NVL(NULL, a) to a.
*
@@ -5414,6 +5448,11 @@ public class Settings
return this;
}
+ public Settings withTransformPatternsFlattenCaseAbbreviation(Boolean value) {
+ setTransformPatternsFlattenCaseAbbreviation(value);
+ return this;
+ }
+
public Settings withTransformPatternsTrivialCaseAbbreviation(Boolean value) {
setTransformPatternsTrivialCaseAbbreviation(value);
return this;
@@ -6400,6 +6439,7 @@ public class Settings
builder.append("transformPatternsCaseMergeWhenElse", transformPatternsCaseMergeWhenElse);
builder.append("transformPatternsCaseToCaseAbbreviation", transformPatternsCaseToCaseAbbreviation);
builder.append("transformPatternsSimplifyCaseAbbreviation", transformPatternsSimplifyCaseAbbreviation);
+ builder.append("transformPatternsFlattenCaseAbbreviation", transformPatternsFlattenCaseAbbreviation);
builder.append("transformPatternsTrivialCaseAbbreviation", transformPatternsTrivialCaseAbbreviation);
builder.append("transformPatternsTrivialPredicates", transformPatternsTrivialPredicates);
builder.append("transformPatternsScalarSubqueryCountAsteriskGtZero", transformPatternsScalarSubqueryCountAsteriskGtZero);
@@ -7167,6 +7207,15 @@ public class Settings
return false;
}
}
+ if (transformPatternsFlattenCaseAbbreviation == null) {
+ if (other.transformPatternsFlattenCaseAbbreviation!= null) {
+ return false;
+ }
+ } else {
+ if (!transformPatternsFlattenCaseAbbreviation.equals(other.transformPatternsFlattenCaseAbbreviation)) {
+ return false;
+ }
+ }
if (transformPatternsTrivialCaseAbbreviation == null) {
if (other.transformPatternsTrivialCaseAbbreviation!= null) {
return false;
@@ -8288,6 +8337,7 @@ public class Settings
result = ((prime*result)+((transformPatternsCaseMergeWhenElse == null)? 0 :transformPatternsCaseMergeWhenElse.hashCode()));
result = ((prime*result)+((transformPatternsCaseToCaseAbbreviation == null)? 0 :transformPatternsCaseToCaseAbbreviation.hashCode()));
result = ((prime*result)+((transformPatternsSimplifyCaseAbbreviation == null)? 0 :transformPatternsSimplifyCaseAbbreviation.hashCode()));
+ result = ((prime*result)+((transformPatternsFlattenCaseAbbreviation == null)? 0 :transformPatternsFlattenCaseAbbreviation.hashCode()));
result = ((prime*result)+((transformPatternsTrivialCaseAbbreviation == null)? 0 :transformPatternsTrivialCaseAbbreviation.hashCode()));
result = ((prime*result)+((transformPatternsTrivialPredicates == null)? 0 :transformPatternsTrivialPredicates.hashCode()));
result = ((prime*result)+((transformPatternsScalarSubqueryCountAsteriskGtZero == null)? 0 :transformPatternsScalarSubqueryCountAsteriskGtZero.hashCode()));
diff --git a/jOOQ/src/main/java/org/jooq/impl/Coalesce.java b/jOOQ/src/main/java/org/jooq/impl/Coalesce.java
index 3e9bd31032..4a7dd13063 100644
--- a/jOOQ/src/main/java/org/jooq/impl/Coalesce.java
+++ b/jOOQ/src/main/java/org/jooq/impl/Coalesce.java
@@ -42,6 +42,8 @@ import static org.jooq.impl.SQLDataType.OTHER;
import static org.jooq.impl.Tools.EMPTY_FIELD;
import static org.jooq.impl.Tools.anyNotNull;
+import java.util.Collection;
+
import org.jooq.Context;
import org.jooq.DataType;
import org.jooq.Field;
@@ -55,6 +57,10 @@ final class Coalesce
+Nested
+This feature is available in the commercial distribution only.]]>
$concat(UnmodifiableList
other) {
+
+ /**
+ * Concatenate a collection to this UnmodifiableList, returning a new
+ * UnmodifiableList from the combined data.
+ */
+ @NotNull
+ default UnmodifiableList
$concat(Collection extends Q> other) {
QueryPartList
r = new QueryPartList<>(this);
r.addAll(other);
return unmodifiable(r);
}
- @NotNull default UnmodifiableList
$removeFirst() {
+ /**
+ * Return a new UnmodifiableList without the element at the argument
+ * position.
+ */
+ @NotNull
+ default UnmodifiableList
$remove(int position) {
+ QueryPartList
r = new QueryPartList<>();
+
+ for (int i = 0; i < size(); i++)
+ if (i != position)
+ r.add(get(i));
+
+ return unmodifiable(r);
+ }
+
+ /**
+ * Access the first element if available.
+ */
+ @Nullable
+ default Q $first() {
+ return isEmpty() ? null : get(0);
+ }
+
+ /**
+ * Access the last element if available.
+ */
+ @Nullable
+ default Q $last() {
+ return isEmpty() ? null : get(size() - 1);
+ }
+
+ /**
+ * Return a new UnmodifiableList without the {@link #$first()} element.
+ */
+ @NotNull
+ default UnmodifiableList
$removeFirst() {
QueryPartList
r = new QueryPartList<>();
for (int i = 1; i < size(); i++)
@@ -293,7 +334,26 @@ public final class QOM {
return unmodifiable(r);
}
- @NotNull default UnmodifiableList
$set(int position, Q newValue) {
+ /**
+ * Return a new {@link UnmodifiableList} without the {@link #$last()}
+ * element.
+ */
+ @NotNull
+ default UnmodifiableList
$removeLast() {
+ QueryPartList
r = new QueryPartList<>();
+
+ for (int i = 0; i < size() - 1; i++)
+ r.add(get(i));
+
+ return unmodifiable(r);
+ }
+
+ /**
+ * Return a new {@link UnmodifiableList} with a new, replaced value at
+ * the argument position.
+ */
+ @NotNull
+ default UnmodifiableList
$set(int position, Q newValue) {
QueryPartList
r = new QueryPartList<>();
for (int i = 0; i < size(); i++)
@@ -305,32 +365,22 @@ public final class QOM {
return unmodifiable(r);
}
- @NotNull default UnmodifiableList
$remove(int position) {
+ /**
+ * Return a new {@link UnmodifiableList} with a new, replaced set of
+ * values at the argument position.
+ */
+ @NotNull
+ default UnmodifiableList
$setAll(int position, Collection extends Q> newValues) {
QueryPartList
r = new QueryPartList<>();
for (int i = 0; i < size(); i++)
- if (i != position)
+ if (i == position)
+ r.addAll(newValues);
+ else
r.add(get(i));
return unmodifiable(r);
}
-
- @NotNull default UnmodifiableList
$removeLast() {
- QueryPartList
r = new QueryPartList<>();
-
- for (int i = 0; i < size() - 1; i++)
- r.add(get(i));
-
- return unmodifiable(r);
- }
-
- @Nullable default Q $first() {
- return isEmpty() ? null : get(0);
- }
-
- @Nullable default Q $last() {
- return isEmpty() ? null : get(size() - 1);
- }
}
public /*sealed*/ interface With
diff --git a/jOOQ/src/main/resources/org/jooq/xsd/jooq-runtime-3.18.0.xsd b/jOOQ/src/main/resources/org/jooq/xsd/jooq-runtime-3.18.0.xsd
index b8165ea76b..24cfe71390 100644
--- a/jOOQ/src/main/resources/org/jooq/xsd/jooq-runtime-3.18.0.xsd
+++ b/jOOQ/src/main/resources/org/jooq/xsd/jooq-runtime-3.18.0.xsd
@@ -624,6 +624,18 @@ Some predicates can be simplified into case abbreviations, such as, for example
This feature is available in the commercial distribution only.]]>
+
NVL or CASE.
+CASE abbreviations can be flattened, as such:
+
+
+NVL(NVL(a, b), c) to COALESCE(a, b, c)COALESCE(a, ..., COALESCE(b, ..., c), ..., d) to COALESCE(a, ..., b, ..., c, ..., d)a.