From 9f4007716a24b87ad8bd497750889229bb5a4bf0 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Mon, 21 Nov 2022 10:18:40 +0100 Subject: [PATCH] [jOOQ/jOOQ#13593] transformPatternsArithmeticComparisons --- .../src/main/java/org/jooq/conf/Settings.java | 50 +++++++++++++++++++ .../src/main/java/org/jooq/impl/Patterns.java | 24 +++++++++ .../org/jooq/xsd/jooq-runtime-3.18.0.xsd | 12 +++++ 3 files changed, 86 insertions(+) diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java index ad3fdbd687..2fe6e36ba7 100644 --- a/jOOQ/src/main/java/org/jooq/conf/Settings.java +++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java @@ -247,6 +247,8 @@ public class Settings @XmlElement(defaultValue = "true") protected Boolean transformPatternsIdempotentFunctionRepetition = true; @XmlElement(defaultValue = "true") + protected Boolean transformPatternsArithmeticComparisons = true; + @XmlElement(defaultValue = "true") protected Boolean transformPatternsArithmeticExpressions = true; @XmlElement(defaultValue = "true") protected Boolean transformPatternsTrigonometricFunctions = true; @@ -3257,6 +3259,38 @@ public class Settings this.transformPatternsIdempotentFunctionRepetition = value; } + /** + * Transform a + 1 = 2 to a = 2 - 1, and other transformations. + *

+ * It is usually best to compare single columns with constants or expressions to + * encourage index usage. While function based indexes are possible in some RDBMS, + * ordinary indexes are more reusable and should be preferred. + *

+ * 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 isTransformPatternsArithmeticComparisons() { + return transformPatternsArithmeticComparisons; + } + + /** + * Sets the value of the transformPatternsArithmeticComparisons property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setTransformPatternsArithmeticComparisons(Boolean value) { + this.transformPatternsArithmeticComparisons = value; + } + /** * Transform 1 / y * x to x / y, and other transformations. *

@@ -6163,6 +6197,11 @@ public class Settings return this; } + public Settings withTransformPatternsArithmeticComparisons(Boolean value) { + setTransformPatternsArithmeticComparisons(value); + return this; + } + public Settings withTransformPatternsArithmeticExpressions(Boolean value) { setTransformPatternsArithmeticExpressions(value); return this; @@ -7136,6 +7175,7 @@ public class Settings builder.append("transformPatternsBitNotBitXNor", transformPatternsBitNotBitXNor); builder.append("transformPatternsNullOnNullInput", transformPatternsNullOnNullInput); builder.append("transformPatternsIdempotentFunctionRepetition", transformPatternsIdempotentFunctionRepetition); + builder.append("transformPatternsArithmeticComparisons", transformPatternsArithmeticComparisons); builder.append("transformPatternsArithmeticExpressions", transformPatternsArithmeticExpressions); builder.append("transformPatternsTrigonometricFunctions", transformPatternsTrigonometricFunctions); builder.append("transformPatternsLogarithmicFunctions", transformPatternsLogarithmicFunctions); @@ -8146,6 +8186,15 @@ public class Settings return false; } } + if (transformPatternsArithmeticComparisons == null) { + if (other.transformPatternsArithmeticComparisons!= null) { + return false; + } + } else { + if (!transformPatternsArithmeticComparisons.equals(other.transformPatternsArithmeticComparisons)) { + return false; + } + } if (transformPatternsArithmeticExpressions == null) { if (other.transformPatternsArithmeticExpressions!= null) { return false; @@ -9214,6 +9263,7 @@ public class Settings result = ((prime*result)+((transformPatternsBitNotBitXNor == null)? 0 :transformPatternsBitNotBitXNor.hashCode())); result = ((prime*result)+((transformPatternsNullOnNullInput == null)? 0 :transformPatternsNullOnNullInput.hashCode())); result = ((prime*result)+((transformPatternsIdempotentFunctionRepetition == null)? 0 :transformPatternsIdempotentFunctionRepetition.hashCode())); + result = ((prime*result)+((transformPatternsArithmeticComparisons == null)? 0 :transformPatternsArithmeticComparisons.hashCode())); result = ((prime*result)+((transformPatternsArithmeticExpressions == null)? 0 :transformPatternsArithmeticExpressions.hashCode())); result = ((prime*result)+((transformPatternsTrigonometricFunctions == null)? 0 :transformPatternsTrigonometricFunctions.hashCode())); result = ((prime*result)+((transformPatternsLogarithmicFunctions == null)? 0 :transformPatternsLogarithmicFunctions.hashCode())); diff --git a/jOOQ/src/main/java/org/jooq/impl/Patterns.java b/jOOQ/src/main/java/org/jooq/impl/Patterns.java index 7b96d793fa..6c3b0409d7 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Patterns.java +++ b/jOOQ/src/main/java/org/jooq/impl/Patterns.java @@ -2538,6 +2538,30 @@ package org.jooq.impl; + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jOOQ/src/main/resources/org/jooq/xsd/jooq-runtime-3.18.0.xsd b/jOOQ/src/main/resources/org/jooq/xsd/jooq-runtime-3.18.0.xsd index c26878d0e0..48d3ff39d5 100644 --- a/jOOQ/src/main/resources/org/jooq/xsd/jooq-runtime-3.18.0.xsd +++ b/jOOQ/src/main/resources/org/jooq/xsd/jooq-runtime-3.18.0.xsd @@ -925,6 +925,18 @@ To enable this feature, {@link #transformPatterns} must be enabled as well. This feature is available in the commercial distribution only.]]> + + a + 1 = 2 to a = 2 - 1, and other transformations. +

+It is usually best to compare single columns with constants or expressions to +encourage index usage. While function based indexes are possible in some RDBMS, +ordinary indexes are more reusable and should be preferred. +

+To enable this feature, {@link #transformPatterns} must be enabled as well. +

+This feature is available in the commercial distribution only.]]> + + 1 / y * x to x / y, and other transformations.