[jOOQ/jOOQ#7284] Replace common patterns in query object model
- NOT truth value - NOT comparison
This commit is contained in:
parent
74aec2ac91
commit
9869baf120
@ -118,12 +118,16 @@ public class Settings
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean transformPatternsNotNot = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean transformPatternsNotTruthValue = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean transformPatternsNotComparison = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean transformPatternsNotNotDistinct = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean transformPatternsNegNeg = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean transformPatternsBitNotBitNot = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean transformPatternsNotNotDistinct = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean transformPatternsIdempotentFunctionRepetition = true;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean transformAnsiJoinToTableLists = false;
|
||||
@ -1153,7 +1157,7 @@ public class Settings
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform <code>LTRIM(RTRIM(x))</code> or <code>RTRIM(LTRIM(x))</code> to <code>TRIM(x)</code>
|
||||
* Transform <code>LTRIM(RTRIM(x))</code> or <code>RTRIM(LTRIM(x))</code> to <code>TRIM(x)</code>.
|
||||
* <p>
|
||||
* Historically, a few dialects did not implement <code>TRIM(x)</code> or <code>TRIM(BOTH FROM x)</code>,
|
||||
* so users worked around this by wrapping <code>LTRIM()</code> and <code>RTRIM()</code> with each other.
|
||||
@ -1185,7 +1189,7 @@ public class Settings
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform <code>NOT(NOT(x))</code> to <code>x</code>
|
||||
* Transform <code>NOT(NOT(x))</code> to <code>x</code>.
|
||||
* <p>
|
||||
* This transformation removes a redundant logic negation.
|
||||
* <p>
|
||||
@ -1214,6 +1218,92 @@ public class Settings
|
||||
this.transformPatternsNotNot = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform <code>NOT(TRUE)</code> to <code>FALSE</code> and <code>NOT(FALSE)</code> to <code>TRUE</code>.
|
||||
* <p>
|
||||
* This transformation removes a redundant logic negation of truth values.
|
||||
* <p>
|
||||
* To enable this feature, {@link #transformPatterns} must be enabled as well.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isTransformPatternsNotTruthValue() {
|
||||
return transformPatternsNotTruthValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the transformPatternsNotTruthValue property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setTransformPatternsNotTruthValue(Boolean value) {
|
||||
this.transformPatternsNotTruthValue = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform <code>NOT (a != b)</code> to <code>a = b/code>, and similar comparisons.
|
||||
* <p>
|
||||
* This transformation removes a redundant logical negation from the <code>DISTINCT</code> predicate.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isTransformPatternsNotComparison() {
|
||||
return transformPatternsNotComparison;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the transformPatternsNotComparison property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setTransformPatternsNotComparison(Boolean value) {
|
||||
this.transformPatternsNotComparison = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform <code>NOT (a IS NOT DISTINCT FROM b)</code> to <code>a IS DISTINCT FROM b</code>.
|
||||
* <p>
|
||||
* This transformation removes a redundant logical negation from the <code>DISTINCT</code> predicate.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isTransformPatternsNotNotDistinct() {
|
||||
return transformPatternsNotNotDistinct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the transformPatternsNotNotDistinct property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setTransformPatternsNotNotDistinct(Boolean value) {
|
||||
this.transformPatternsNotNotDistinct = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform <code>-(-(x))</code> to <code>x</code>
|
||||
* <p>
|
||||
@ -1275,35 +1365,7 @@ public class Settings
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform <code>NOT (a IS NOT DISTINCT FROM b)</code> to <code>a IS DISTINCT FROM b</code>
|
||||
* <p>
|
||||
* This transformation removes a redundant logical negation from the <code>DISTINCT</code> predicate.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isTransformPatternsNotNotDistinct() {
|
||||
return transformPatternsNotNotDistinct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the transformPatternsNotNotDistinct property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setTransformPatternsNotNotDistinct(Boolean value) {
|
||||
this.transformPatternsNotNotDistinct = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform all repetitions of idempotent functions, such as <code>UPPER(UPPER(s))</code> to <code>UPPER(s)</code>
|
||||
* Transform all repetitions of idempotent functions, such as <code>UPPER(UPPER(s))</code> to <code>UPPER(s)</code>.
|
||||
* <p>
|
||||
* Idempotent functions that are covered so far, include:
|
||||
* <ul>
|
||||
@ -3591,6 +3653,21 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withTransformPatternsNotTruthValue(Boolean value) {
|
||||
setTransformPatternsNotTruthValue(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withTransformPatternsNotComparison(Boolean value) {
|
||||
setTransformPatternsNotComparison(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withTransformPatternsNotNotDistinct(Boolean value) {
|
||||
setTransformPatternsNotNotDistinct(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withTransformPatternsNegNeg(Boolean value) {
|
||||
setTransformPatternsNegNeg(value);
|
||||
return this;
|
||||
@ -3601,11 +3678,6 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withTransformPatternsNotNotDistinct(Boolean value) {
|
||||
setTransformPatternsNotNotDistinct(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withTransformPatternsIdempotentFunctionRepetition(Boolean value) {
|
||||
setTransformPatternsIdempotentFunctionRepetition(value);
|
||||
return this;
|
||||
@ -4437,9 +4509,11 @@ public class Settings
|
||||
builder.append("transformPatterns", transformPatterns);
|
||||
builder.append("transformPatternsTrim", transformPatternsTrim);
|
||||
builder.append("transformPatternsNotNot", transformPatternsNotNot);
|
||||
builder.append("transformPatternsNotTruthValue", transformPatternsNotTruthValue);
|
||||
builder.append("transformPatternsNotComparison", transformPatternsNotComparison);
|
||||
builder.append("transformPatternsNotNotDistinct", transformPatternsNotNotDistinct);
|
||||
builder.append("transformPatternsNegNeg", transformPatternsNegNeg);
|
||||
builder.append("transformPatternsBitNotBitNot", transformPatternsBitNotBitNot);
|
||||
builder.append("transformPatternsNotNotDistinct", transformPatternsNotNotDistinct);
|
||||
builder.append("transformPatternsIdempotentFunctionRepetition", transformPatternsIdempotentFunctionRepetition);
|
||||
builder.append("transformAnsiJoinToTableLists", transformAnsiJoinToTableLists);
|
||||
builder.append("transformInConditionSubqueryWithLimitToDerivedTable", transformInConditionSubqueryWithLimitToDerivedTable);
|
||||
@ -4863,6 +4937,33 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (transformPatternsNotTruthValue == null) {
|
||||
if (other.transformPatternsNotTruthValue!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!transformPatternsNotTruthValue.equals(other.transformPatternsNotTruthValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (transformPatternsNotComparison == null) {
|
||||
if (other.transformPatternsNotComparison!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!transformPatternsNotComparison.equals(other.transformPatternsNotComparison)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (transformPatternsNotNotDistinct == null) {
|
||||
if (other.transformPatternsNotNotDistinct!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!transformPatternsNotNotDistinct.equals(other.transformPatternsNotNotDistinct)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (transformPatternsNegNeg == null) {
|
||||
if (other.transformPatternsNegNeg!= null) {
|
||||
return false;
|
||||
@ -4881,15 +4982,6 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (transformPatternsNotNotDistinct == null) {
|
||||
if (other.transformPatternsNotNotDistinct!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!transformPatternsNotNotDistinct.equals(other.transformPatternsNotNotDistinct)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (transformPatternsIdempotentFunctionRepetition == null) {
|
||||
if (other.transformPatternsIdempotentFunctionRepetition!= null) {
|
||||
return false;
|
||||
@ -5795,9 +5887,11 @@ public class Settings
|
||||
result = ((prime*result)+((transformPatterns == null)? 0 :transformPatterns.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsTrim == null)? 0 :transformPatternsTrim.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsNotNot == null)? 0 :transformPatternsNotNot.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsNotTruthValue == null)? 0 :transformPatternsNotTruthValue.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsNotComparison == null)? 0 :transformPatternsNotComparison.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsNotNotDistinct == null)? 0 :transformPatternsNotNotDistinct.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsNegNeg == null)? 0 :transformPatternsNegNeg.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsBitNotBitNot == null)? 0 :transformPatternsBitNotBitNot.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsNotNotDistinct == null)? 0 :transformPatternsNotNotDistinct.hashCode()));
|
||||
result = ((prime*result)+((transformPatternsIdempotentFunctionRepetition == null)? 0 :transformPatternsIdempotentFunctionRepetition.hashCode()));
|
||||
result = ((prime*result)+((transformAnsiJoinToTableLists == null)? 0 :transformAnsiJoinToTableLists.hashCode()));
|
||||
result = ((prime*result)+((transformInConditionSubqueryWithLimitToDerivedTable == null)? 0 :transformInConditionSubqueryWithLimitToDerivedTable.hashCode()));
|
||||
|
||||
@ -37,12 +37,15 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.FALSE;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.conf.SettingsTools.renderLocale;
|
||||
import static org.jooq.impl.DSL.falseCondition;
|
||||
import static org.jooq.impl.DSL.trim;
|
||||
import static org.jooq.impl.DSL.trueCondition;
|
||||
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;
|
||||
@ -63,6 +66,7 @@ import java.util.regex.Pattern;
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Constants;
|
||||
import org.jooq.False;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.ForeignKey;
|
||||
import org.jooq.Param;
|
||||
@ -75,6 +79,7 @@ import org.jooq.RenderContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.True;
|
||||
import org.jooq.conf.RenderFormatting;
|
||||
import org.jooq.conf.RenderKeywordCase;
|
||||
import org.jooq.conf.RenderNameCase;
|
||||
@ -84,13 +89,21 @@ import org.jooq.conf.SettingsTools;
|
||||
import org.jooq.exception.ControlFlowSignal;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.impl.QOM.BitNot;
|
||||
import org.jooq.impl.QOM.Eq;
|
||||
import org.jooq.impl.QOM.FieldCondition;
|
||||
import org.jooq.impl.QOM.Ge;
|
||||
import org.jooq.impl.QOM.Gt;
|
||||
import org.jooq.impl.QOM.IsNotDistinctFrom;
|
||||
import org.jooq.impl.QOM.Le;
|
||||
import org.jooq.impl.QOM.Lt;
|
||||
import org.jooq.impl.QOM.Ltrim;
|
||||
import org.jooq.impl.QOM.Ne;
|
||||
import org.jooq.impl.QOM.Neg;
|
||||
import org.jooq.impl.QOM.Not;
|
||||
import org.jooq.impl.QOM.Rtrim;
|
||||
import org.jooq.impl.QOM.Trim;
|
||||
import org.jooq.impl.QOM.Upper;
|
||||
import org.jooq.impl.QOM.Val;
|
||||
import org.jooq.impl.ScopeMarker.ScopeContent;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
import org.jooq.tools.StringUtils;
|
||||
@ -907,6 +920,50 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -281,7 +281,7 @@ This feature is available in the commercial distribution only.]]></jxb:javadoc><
|
||||
</element>
|
||||
|
||||
<element name="transformPatternsTrim" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>LTRIM(RTRIM(x))</code> or <code>RTRIM(LTRIM(x))</code> to <code>TRIM(x)</code>
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>LTRIM(RTRIM(x))</code> or <code>RTRIM(LTRIM(x))</code> to <code>TRIM(x)</code>.
|
||||
<p>
|
||||
Historically, a few dialects did not implement <code>TRIM(x)</code> or <code>TRIM(BOTH FROM x)</code>,
|
||||
so users worked around this by wrapping <code>LTRIM()</code> and <code>RTRIM()</code> with each other.
|
||||
@ -293,7 +293,7 @@ This feature is available in the commercial distribution only.]]></jxb:javadoc><
|
||||
</element>
|
||||
|
||||
<element name="transformPatternsNotNot" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>NOT(NOT(x))</code> to <code>x</code>
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>NOT(NOT(x))</code> to <code>x</code>.
|
||||
<p>
|
||||
This transformation removes a redundant logic negation.
|
||||
<p>
|
||||
@ -302,6 +302,32 @@ 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="transformPatternsNotTruthValue" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>NOT(TRUE)</code> to <code>FALSE</code> and <code>NOT(FALSE)</code> to <code>TRUE</code>.
|
||||
<p>
|
||||
This transformation removes a redundant logic negation of truth values.
|
||||
<p>
|
||||
To enable this feature, {@link #transformPatterns} must be enabled as well.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="transformPatternsNotComparison" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>NOT (a != b)</code> to <code>a = b/code>, and similar comparisons.
|
||||
<p>
|
||||
This transformation removes a redundant logical negation from the <code>DISTINCT</code> predicate.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="transformPatternsNotNotDistinct" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>NOT (a IS NOT DISTINCT FROM b)</code> to <code>a IS DISTINCT FROM b</code>.
|
||||
<p>
|
||||
This transformation removes a redundant logical negation from the <code>DISTINCT</code> predicate.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="transformPatternsNegNeg" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>-(-(x))</code> to <code>x</code>
|
||||
<p>
|
||||
@ -322,16 +348,8 @@ 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="transformPatternsNotNotDistinct" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform <code>NOT (a IS NOT DISTINCT FROM b)</code> to <code>a IS DISTINCT FROM b</code>
|
||||
<p>
|
||||
This transformation removes a redundant logical negation from the <code>DISTINCT</code> predicate.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="transformPatternsIdempotentFunctionRepetition" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform all repetitions of idempotent functions, such as <code>UPPER(UPPER(s))</code> to <code>UPPER(s)</code>
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Transform all repetitions of idempotent functions, such as <code>UPPER(UPPER(s))</code> to <code>UPPER(s)</code>.
|
||||
<p>
|
||||
Idempotent functions that are covered so far, include:
|
||||
<ul>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user