[jOOQ/jOOQ#13593] transformPatternsFlattenCaseAbbreviation
This commit is contained in:
parent
0ae5ebf4df
commit
8abe6dff79
@ -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 <code>CASE</code> abbreviations such as <code>NVL</code> or <code>CASE</code>.
|
||||
* <p>
|
||||
* Nested <code>CASE</code> abbreviations can be flattened, as such:
|
||||
* <ul>
|
||||
* <li><code>NVL(NVL(a, b), c)</code> to <code>COALESCE(a, b, c)</code></li>
|
||||
* <li><code>COALESCE(a, ..., COALESCE(b, ..., c), ..., d)</code> to <code>COALESCE(a, …, b, …, c, ..., d)</code></li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* 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 <code>NVL(NULL, a)</code> to <code>a</code>.
|
||||
* <p>
|
||||
@ -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()));
|
||||
|
||||
@ -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<T> extends AbstractField<T> implements QOM.Coalesce<T> {
|
||||
|
||||
private final Field<T>[] fields;
|
||||
|
||||
Coalesce(Collection<? extends Field<?>> fields) {
|
||||
this(fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
Coalesce(Field<?>[] fields) {
|
||||
super(N_COALESCE, anyNotNull((DataType) OTHER, fields));
|
||||
|
||||
@ -1954,6 +1954,39 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -278,13 +278,54 @@ public final class QOM {
|
||||
|
||||
// TODO: These methods could return unmodifiable views instead, to avoid
|
||||
// copying things around...
|
||||
@NotNull default UnmodifiableList<Q> $concat(UnmodifiableList<Q> other) {
|
||||
|
||||
/**
|
||||
* Concatenate a collection to this UnmodifiableList, returning a new
|
||||
* UnmodifiableList from the combined data.
|
||||
*/
|
||||
@NotNull
|
||||
default UnmodifiableList<Q> $concat(Collection<? extends Q> other) {
|
||||
QueryPartList<Q> r = new QueryPartList<>(this);
|
||||
r.addAll(other);
|
||||
return unmodifiable(r);
|
||||
}
|
||||
|
||||
@NotNull default UnmodifiableList<Q> $removeFirst() {
|
||||
/**
|
||||
* Return a new UnmodifiableList without the element at the argument
|
||||
* position.
|
||||
*/
|
||||
@NotNull
|
||||
default UnmodifiableList<Q> $remove(int position) {
|
||||
QueryPartList<Q> 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<Q> $removeFirst() {
|
||||
QueryPartList<Q> r = new QueryPartList<>();
|
||||
|
||||
for (int i = 1; i < size(); i++)
|
||||
@ -293,7 +334,26 @@ public final class QOM {
|
||||
return unmodifiable(r);
|
||||
}
|
||||
|
||||
@NotNull default UnmodifiableList<Q> $set(int position, Q newValue) {
|
||||
/**
|
||||
* Return a new {@link UnmodifiableList} without the {@link #$last()}
|
||||
* element.
|
||||
*/
|
||||
@NotNull
|
||||
default UnmodifiableList<Q> $removeLast() {
|
||||
QueryPartList<Q> 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<Q> $set(int position, Q newValue) {
|
||||
QueryPartList<Q> r = new QueryPartList<>();
|
||||
|
||||
for (int i = 0; i < size(); i++)
|
||||
@ -305,32 +365,22 @@ public final class QOM {
|
||||
return unmodifiable(r);
|
||||
}
|
||||
|
||||
@NotNull default UnmodifiableList<Q> $remove(int position) {
|
||||
/**
|
||||
* Return a new {@link UnmodifiableList} with a new, replaced set of
|
||||
* values at the argument position.
|
||||
*/
|
||||
@NotNull
|
||||
default UnmodifiableList<Q> $setAll(int position, Collection<? extends Q> newValues) {
|
||||
QueryPartList<Q> 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<Q> $removeLast() {
|
||||
QueryPartList<Q> 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
|
||||
|
||||
@ -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.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="transformPatternsFlattenCaseAbbreviation" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Flatten nested <code>CASE</code> abbreviations such as <code>NVL</code> or <code>CASE</code>.
|
||||
<p>
|
||||
Nested <code>CASE</code> abbreviations can be flattened, as such:
|
||||
<ul>
|
||||
<li><code>NVL(NVL(a, b), c)</code> to <code>COALESCE(a, b, c)</code></li>
|
||||
<li><code>COALESCE(a, ..., COALESCE(b, ..., c), ..., d)</code> to <code>COALESCE(a, ..., b, ..., c, ..., d)</code></li>
|
||||
</ul>
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="transformPatternsTrivialCaseAbbreviation" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform trivial case abbreviations like <code>NVL(NULL, a)</code> to <code>a</code>.
|
||||
<p>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user