[jOOQ/jOOQ#13593] transformPatternsCaseSearchedToCaseSimple

This commit is contained in:
Lukas Eder 2022-11-18 11:35:13 +01:00
parent 6a8c3bd731
commit 25d902d7f6
4 changed files with 91 additions and 0 deletions

View File

@ -193,6 +193,8 @@ public class Settings
@XmlElement(defaultValue = "true")
protected Boolean transformPatternsMergeBetweenSymmetricPredicates = true;
@XmlElement(defaultValue = "true")
protected Boolean transformPatternsCaseSearchedToCaseSimple = true;
@XmlElement(defaultValue = "true")
protected Boolean transformPatternsCaseElseNull = true;
@XmlElement(defaultValue = "true")
protected Boolean transformPatternsUnreachableCaseClauses = true;
@ -2432,6 +2434,35 @@ public class Settings
this.transformPatternsMergeBetweenSymmetricPredicates = value;
}
/**
* Transform a searched <code>CASE WHEN x = .. WHEN x = ..</code> to a simple <code>CASE x WHEN WHEN </code> expression.
* <p>
* When a searched <code>CASE</code> expression always compares the same column to a value, then it can be simplified, possibly
* unlocking further transformations that are available only to the simple <code>CASE</code> expression.
* <p>
* This feature is available in the commercial distribution only.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isTransformPatternsCaseSearchedToCaseSimple() {
return transformPatternsCaseSearchedToCaseSimple;
}
/**
* Sets the value of the transformPatternsCaseSearchedToCaseSimple property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setTransformPatternsCaseSearchedToCaseSimple(Boolean value) {
this.transformPatternsCaseSearchedToCaseSimple = value;
}
/**
* Transform <code>CASE ELSE NULL</code> removing the <code>ELSE</code> clause.
* <p>
@ -5933,6 +5964,11 @@ public class Settings
return this;
}
public Settings withTransformPatternsCaseSearchedToCaseSimple(Boolean value) {
setTransformPatternsCaseSearchedToCaseSimple(value);
return this;
}
public Settings withTransformPatternsCaseElseNull(Boolean value) {
setTransformPatternsCaseElseNull(value);
return this;
@ -6999,6 +7035,7 @@ public class Settings
builder.append("transformPatternsMergeInLists", transformPatternsMergeInLists);
builder.append("transformPatternsMergeRangePredicates", transformPatternsMergeRangePredicates);
builder.append("transformPatternsMergeBetweenSymmetricPredicates", transformPatternsMergeBetweenSymmetricPredicates);
builder.append("transformPatternsCaseSearchedToCaseSimple", transformPatternsCaseSearchedToCaseSimple);
builder.append("transformPatternsCaseElseNull", transformPatternsCaseElseNull);
builder.append("transformPatternsUnreachableCaseClauses", transformPatternsUnreachableCaseClauses);
builder.append("transformPatternsUnreachableDecodeClauses", transformPatternsUnreachableDecodeClauses);
@ -7790,6 +7827,15 @@ public class Settings
return false;
}
}
if (transformPatternsCaseSearchedToCaseSimple == null) {
if (other.transformPatternsCaseSearchedToCaseSimple!= null) {
return false;
}
} else {
if (!transformPatternsCaseSearchedToCaseSimple.equals(other.transformPatternsCaseSearchedToCaseSimple)) {
return false;
}
}
if (transformPatternsCaseElseNull == null) {
if (other.transformPatternsCaseElseNull!= null) {
return false;
@ -9047,6 +9093,7 @@ public class Settings
result = ((prime*result)+((transformPatternsMergeInLists == null)? 0 :transformPatternsMergeInLists.hashCode()));
result = ((prime*result)+((transformPatternsMergeRangePredicates == null)? 0 :transformPatternsMergeRangePredicates.hashCode()));
result = ((prime*result)+((transformPatternsMergeBetweenSymmetricPredicates == null)? 0 :transformPatternsMergeBetweenSymmetricPredicates.hashCode()));
result = ((prime*result)+((transformPatternsCaseSearchedToCaseSimple == null)? 0 :transformPatternsCaseSearchedToCaseSimple.hashCode()));
result = ((prime*result)+((transformPatternsCaseElseNull == null)? 0 :transformPatternsCaseElseNull.hashCode()));
result = ((prime*result)+((transformPatternsUnreachableCaseClauses == null)? 0 :transformPatternsUnreachableCaseClauses.hashCode()));
result = ((prime*result)+((transformPatternsUnreachableDecodeClauses == null)? 0 :transformPatternsUnreachableDecodeClauses.hashCode()));

View File

@ -2462,6 +2462,36 @@ package org.jooq.impl;

View File

@ -56,6 +56,7 @@ import java.util.UUID;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collector;
// ...
import org.jooq.Catalog;
@ -289,6 +290,10 @@ public final class QOM {
// TODO: These methods could return unmodifiable views instead, to avoid
// copying things around...
default <R> R $collect(Collector<Q, ?, R> collector) {
return stream().collect(collector);
}
/**
* Concatenate a collection to this UnmodifiableList, returning a new
* UnmodifiableList from the combined data.

View File

@ -646,6 +646,15 @@ To enable this feature, {@link #transformPatterns} must be enabled as well.
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="transformPatternsCaseSearchedToCaseSimple" type="boolean" minOccurs="0" maxOccurs="1" default="true">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform a searched <code>CASE WHEN x = .. WHEN x = ..</code> to a simple <code>CASE x WHEN .. WHEN ..</code> expression.
<p>
When a searched <code>CASE</code> expression always compares the same column to a value, then it can be simplified, possibly
unlocking further transformations that are available only to the simple <code>CASE</code> expression.
<p>
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="transformPatternsCaseElseNull" type="boolean" minOccurs="0" maxOccurs="1" default="true">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>CASE .. ELSE NULL</code> removing the <code>ELSE</code> clause.
<p>