diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java
index 86fbd3ff62..1841222572 100644
--- a/jOOQ/src/main/java/org/jooq/conf/Settings.java
+++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java
@@ -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 LTRIM(RTRIM(x)) or RTRIM(LTRIM(x)) to TRIM(x)
+ * Transform LTRIM(RTRIM(x)) or RTRIM(LTRIM(x)) to TRIM(x).
*
* Historically, a few dialects did not implement TRIM(x) or TRIM(BOTH FROM x),
* so users worked around this by wrapping LTRIM() and RTRIM() with each other.
@@ -1185,7 +1189,7 @@ public class Settings
}
/**
- * Transform NOT(NOT(x)) to x
+ * Transform NOT(NOT(x)) to x.
*
* This transformation removes a redundant logic negation. *
@@ -1214,6 +1218,92 @@ public class Settings
this.transformPatternsNotNot = value;
}
+ /**
+ * Transform NOT(TRUE) to FALSE and NOT(FALSE) to TRUE.
+ *
+ * This transformation removes a redundant logic negation of truth values. + *
+ * To enable this feature, {@link #transformPatterns} must be enabled as well. + *
+ * 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
+ * This transformation removes a redundant logical negation from the
+ * 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
+ * This transformation removes a redundant logical negation from the
+ * 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
@@ -1275,35 +1365,7 @@ public class Settings
}
/**
- * Transform
- * This transformation removes a redundant logical negation from the
- * 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
* Idempotent functions that are covered so far, include:
*
Historically, a few dialects did not implement
This transformation removes a redundant logic negation.
@@ -302,6 +302,32 @@ To enable this feature, {@link #transformPatterns} must be enabled as well.
This feature is available in the commercial distribution only.]]>
+This transformation removes a redundant logic negation of truth values.
+
+To enable this feature, {@link #transformPatterns} must be enabled as well.
+
+This feature is available in the commercial distribution only.]]>
+This transformation removes a redundant logical negation from the
+This feature is available in the commercial distribution only.]]>
+This transformation removes a redundant logical negation from the
+This feature is available in the commercial distribution only.]]>
@@ -322,16 +348,8 @@ To enable this feature, {@link #transformPatterns} must be enabled as well.
This feature is available in the commercial distribution only.]]>
-This transformation removes a redundant logical negation from the
-This feature is available in the commercial distribution only.]]>
Idempotent functions that are covered so far, include:
NOT (a != b) to a = b/code>, and similar comparisons.
+ * or DISTINCT predicate.
+ * NOT (a IS NOT DISTINCT FROM b) to a IS DISTINCT FROM b.
+ * DISTINCT predicate.
+ * -(-(x)) to x
* NOT (a IS NOT DISTINCT FROM b) to a IS DISTINCT FROM b
- * DISTINCT predicate.
- * UPPER(UPPER(s)) to UPPER(s)
+ * Transform all repetitions of idempotent functions, such as UPPER(UPPER(s)) to UPPER(s).
*
@@ -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()));
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
index f2b19e7546..3b5c51edf5 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
@@ -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
RTRIM(LTRIM(x)) to TRIM(x)
+ RTRIM(LTRIM(x)) to TRIM(x).
TRIM(x) or TRIM(BOTH FROM x),
so users worked around this by wrapping LTRIM() and RTRIM() with each other.
@@ -293,7 +293,7 @@ This feature is available in the commercial distribution only.]]>x
+ x.
FALSE and NOT(FALSE) to TRUE.
+a = b/code>, and similar comparisons.
+DISTINCT predicate.
+a IS DISTINCT FROM b.
+DISTINCT predicate.
+x
a IS DISTINCT FROM b
-DISTINCT predicate.
-UPPER(s)
+ UPPER(s).