diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java index 1841222572..cfe278fccd 100644 --- a/jOOQ/src/main/java/org/jooq/conf/Settings.java +++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java @@ -124,6 +124,8 @@ public class Settings @XmlElement(defaultValue = "true") protected Boolean transformPatternsNotNotDistinct = true; @XmlElement(defaultValue = "true") + protected Boolean transformPatternsTrivialPredicates = true; + @XmlElement(defaultValue = "true") protected Boolean transformPatternsNegNeg = true; @XmlElement(defaultValue = "true") protected Boolean transformPatternsBitNotBitNot = true; @@ -1253,6 +1255,8 @@ public class Settings *
* This transformation removes a redundant logical negation from the DISTINCT predicate.
*
+ * To enable this feature, {@link #transformPatterns} must be enabled as well. + *
* This feature is available in the commercial distribution only. * * @return @@ -1281,6 +1285,8 @@ public class Settings *
* This transformation removes a redundant logical negation from the DISTINCT predicate.
*
+ * To enable this feature, {@link #transformPatterns} must be enabled as well. + *
* This feature is available in the commercial distribution only.
*
* @return
@@ -1304,6 +1310,34 @@ public class Settings
this.transformPatternsNotNotDistinct = value;
}
+ /**
+ * Transform trivial predicates like 1 = 1 to TRUE.
+ *
+ * This transformation removes any trivial predicates. + *
+ * This feature is available in the commercial distribution only.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public Boolean isTransformPatternsTrivialPredicates() {
+ return transformPatternsTrivialPredicates;
+ }
+
+ /**
+ * Sets the value of the transformPatternsTrivialPredicates property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setTransformPatternsTrivialPredicates(Boolean value) {
+ this.transformPatternsTrivialPredicates = value;
+ }
+
/**
* Transform -(-(x)) to x
*
@@ -1379,6 +1413,8 @@ public class Settings *
LOWER(LOWER(s)) to LOWER(s)+ * To enable this feature, {@link #transformPatterns} must be enabled as well. + *
* This feature is available in the commercial distribution only.
*
* @return
@@ -3668,6 +3704,11 @@ public class Settings
return this;
}
+ public Settings withTransformPatternsTrivialPredicates(Boolean value) {
+ setTransformPatternsTrivialPredicates(value);
+ return this;
+ }
+
public Settings withTransformPatternsNegNeg(Boolean value) {
setTransformPatternsNegNeg(value);
return this;
@@ -4512,6 +4553,7 @@ public class Settings
builder.append("transformPatternsNotTruthValue", transformPatternsNotTruthValue);
builder.append("transformPatternsNotComparison", transformPatternsNotComparison);
builder.append("transformPatternsNotNotDistinct", transformPatternsNotNotDistinct);
+ builder.append("transformPatternsTrivialPredicates", transformPatternsTrivialPredicates);
builder.append("transformPatternsNegNeg", transformPatternsNegNeg);
builder.append("transformPatternsBitNotBitNot", transformPatternsBitNotBitNot);
builder.append("transformPatternsIdempotentFunctionRepetition", transformPatternsIdempotentFunctionRepetition);
@@ -4964,6 +5006,15 @@ public class Settings
return false;
}
}
+ if (transformPatternsTrivialPredicates == null) {
+ if (other.transformPatternsTrivialPredicates!= null) {
+ return false;
+ }
+ } else {
+ if (!transformPatternsTrivialPredicates.equals(other.transformPatternsTrivialPredicates)) {
+ return false;
+ }
+ }
if (transformPatternsNegNeg == null) {
if (other.transformPatternsNegNeg!= null) {
return false;
@@ -5890,6 +5941,7 @@ public class Settings
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)+((transformPatternsTrivialPredicates == null)? 0 :transformPatternsTrivialPredicates.hashCode()));
result = ((prime*result)+((transformPatternsNegNeg == null)? 0 :transformPatternsNegNeg.hashCode()));
result = ((prime*result)+((transformPatternsBitNotBitNot == null)? 0 :transformPatternsBitNotBitNot.hashCode()));
result = ((prime*result)+((transformPatternsIdempotentFunctionRepetition == null)? 0 :transformPatternsIdempotentFunctionRepetition.hashCode()));
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
index 3b5c51edf5..23522a0eff 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java
@@ -60,10 +60,12 @@ import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;
import org.jooq.BindContext;
+import org.jooq.Condition;
import org.jooq.Configuration;
import org.jooq.Constants;
import org.jooq.False;
@@ -88,6 +90,7 @@ import org.jooq.conf.Settings;
import org.jooq.conf.SettingsTools;
import org.jooq.exception.ControlFlowSignal;
import org.jooq.exception.DataAccessException;
+import org.jooq.impl.QOM.And;
import org.jooq.impl.QOM.BitNot;
import org.jooq.impl.QOM.Eq;
import org.jooq.impl.QOM.FieldCondition;
@@ -100,6 +103,7 @@ 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.Or;
import org.jooq.impl.QOM.Rtrim;
import org.jooq.impl.QOM.Trim;
import org.jooq.impl.QOM.Upper;
@@ -108,6 +112,8 @@ import org.jooq.impl.ScopeMarker.ScopeContent;
import org.jooq.tools.JooqLogger;
import org.jooq.tools.StringUtils;
+import org.jetbrains.annotations.NotNull;
+
/**
* @author Lukas Eder
*/
@@ -964,6 +970,58 @@ class DefaultRenderContext extends AbstractContext
This transformation removes a redundant logical negation from the
+To enable this feature, {@link #transformPatterns} must be enabled as well.
+
This feature is available in the commercial distribution only.]]>
@@ -325,6 +327,16 @@ This feature is available in the commercial distribution only.]]><
This transformation removes a redundant logical negation from the
+To enable this feature, {@link #transformPatterns} must be enabled as well.
+
+This feature is available in the commercial distribution only.]]>
+
+
+
+This transformation removes any trivial predicates.
+
This feature is available in the commercial distribution only.]]>
+To enable this feature, {@link #transformPatterns} must be enabled as well.
+
This feature is available in the commercial distribution only.]]>
DISTINCT predicate.
DISTINCT predicate.
TRUE.
+LOWER(LOWER(s)) to LOWER(s)