[jOOQ/jOOQ#7527] possiblyWrongExpression: Wrong MOD check
This commit is contained in:
parent
e9095af4eb
commit
ed34cd7516
@ -385,6 +385,23 @@ public interface DiagnosticsListener {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -127,7 +127,9 @@ public class Settings
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean diagnosticsConsecutiveAggregation = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean diagnosticsConcatenationInPredicates = true;
|
||||
protected Boolean diagnosticsConcatenationInPredicate = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean diagnosticsPossiblyWrongExpression = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean diagnosticsTooManyColumnsFetched = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
@ -1443,7 +1445,7 @@ public class Settings
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to run the {@link org.jooq.DiagnosticsListener#concatenationInPredicates(org.jooq.DiagnosticsContext) diagnostic.
|
||||
* Whether to run the {@link org.jooq.DiagnosticsListener#concatenationInPredicate(org.jooq.DiagnosticsContext) diagnostic.
|
||||
* <p>
|
||||
* Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured.
|
||||
* Once configured, this diagnostic is turned on by default.
|
||||
@ -1455,20 +1457,49 @@ public class Settings
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isDiagnosticsConcatenationInPredicates() {
|
||||
return diagnosticsConcatenationInPredicates;
|
||||
public Boolean isDiagnosticsConcatenationInPredicate() {
|
||||
return diagnosticsConcatenationInPredicate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the diagnosticsConcatenationInPredicates property.
|
||||
* Sets the value of the diagnosticsConcatenationInPredicate property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setDiagnosticsConcatenationInPredicates(Boolean value) {
|
||||
this.diagnosticsConcatenationInPredicates = value;
|
||||
public void setDiagnosticsConcatenationInPredicate(Boolean value) {
|
||||
this.diagnosticsConcatenationInPredicate = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to run the {@link org.jooq.DiagnosticsListener#possiblyWrongExpression(org.jooq.DiagnosticsContext) diagnostic.
|
||||
* <p>
|
||||
* Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured.
|
||||
* Once configured, this diagnostic is turned on by default.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isDiagnosticsPossiblyWrongExpression() {
|
||||
return diagnosticsPossiblyWrongExpression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the diagnosticsPossiblyWrongExpression property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setDiagnosticsPossiblyWrongExpression(Boolean value) {
|
||||
this.diagnosticsPossiblyWrongExpression = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5672,8 +5703,13 @@ public class Settings
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withDiagnosticsConcatenationInPredicates(Boolean value) {
|
||||
setDiagnosticsConcatenationInPredicates(value);
|
||||
public Settings withDiagnosticsConcatenationInPredicate(Boolean value) {
|
||||
setDiagnosticsConcatenationInPredicate(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Settings withDiagnosticsPossiblyWrongExpression(Boolean value) {
|
||||
setDiagnosticsPossiblyWrongExpression(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -6855,7 +6891,8 @@ public class Settings
|
||||
builder.append("diagnosticsMissingWasNullCall", diagnosticsMissingWasNullCall);
|
||||
builder.append("diagnosticsRepeatedStatements", diagnosticsRepeatedStatements);
|
||||
builder.append("diagnosticsConsecutiveAggregation", diagnosticsConsecutiveAggregation);
|
||||
builder.append("diagnosticsConcatenationInPredicates", diagnosticsConcatenationInPredicates);
|
||||
builder.append("diagnosticsConcatenationInPredicate", diagnosticsConcatenationInPredicate);
|
||||
builder.append("diagnosticsPossiblyWrongExpression", diagnosticsPossiblyWrongExpression);
|
||||
builder.append("diagnosticsTooManyColumnsFetched", diagnosticsTooManyColumnsFetched);
|
||||
builder.append("diagnosticsTooManyRowsFetched", diagnosticsTooManyRowsFetched);
|
||||
builder.append("diagnosticsUnnecessaryWasNullCall", diagnosticsUnnecessaryWasNullCall);
|
||||
@ -7379,12 +7416,21 @@ public class Settings
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (diagnosticsConcatenationInPredicates == null) {
|
||||
if (other.diagnosticsConcatenationInPredicates!= null) {
|
||||
if (diagnosticsConcatenationInPredicate == null) {
|
||||
if (other.diagnosticsConcatenationInPredicate!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!diagnosticsConcatenationInPredicates.equals(other.diagnosticsConcatenationInPredicates)) {
|
||||
if (!diagnosticsConcatenationInPredicate.equals(other.diagnosticsConcatenationInPredicate)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (diagnosticsPossiblyWrongExpression == null) {
|
||||
if (other.diagnosticsPossiblyWrongExpression!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!diagnosticsPossiblyWrongExpression.equals(other.diagnosticsPossiblyWrongExpression)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -8873,7 +8919,8 @@ public class Settings
|
||||
result = ((prime*result)+((diagnosticsMissingWasNullCall == null)? 0 :diagnosticsMissingWasNullCall.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsRepeatedStatements == null)? 0 :diagnosticsRepeatedStatements.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsConsecutiveAggregation == null)? 0 :diagnosticsConsecutiveAggregation.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsConcatenationInPredicates == null)? 0 :diagnosticsConcatenationInPredicates.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsConcatenationInPredicate == null)? 0 :diagnosticsConcatenationInPredicate.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsPossiblyWrongExpression == null)? 0 :diagnosticsPossiblyWrongExpression.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsTooManyColumnsFetched == null)? 0 :diagnosticsTooManyColumnsFetched.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsTooManyRowsFetched == null)? 0 :diagnosticsTooManyRowsFetched.hashCode()));
|
||||
result = ((prime*result)+((diagnosticsUnnecessaryWasNullCall == null)? 0 :diagnosticsUnnecessaryWasNullCall.hashCode()));
|
||||
|
||||
@ -46,6 +46,7 @@ import static org.jooq.conf.DiagnosticsConnection.OFF;
|
||||
import static org.jooq.conf.ParamType.FORCE_INDEXED;
|
||||
import static org.jooq.impl.DSL.count;
|
||||
import static org.jooq.impl.DSL.noCondition;
|
||||
import static org.jooq.impl.QOM.commutativeCheck;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
@ -64,6 +65,7 @@ import java.util.function.Predicate;
|
||||
import org.jooq.AggregateFunction;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Parser;
|
||||
// ...
|
||||
import org.jooq.Queries;
|
||||
@ -78,7 +80,10 @@ import org.jooq.impl.QOM.Concat;
|
||||
import org.jooq.impl.QOM.Eq;
|
||||
import org.jooq.impl.QOM.In;
|
||||
import org.jooq.impl.QOM.InList;
|
||||
import org.jooq.impl.QOM.IsDistinctFrom;
|
||||
import org.jooq.impl.QOM.Mod;
|
||||
import org.jooq.impl.QOM.NotInList;
|
||||
import org.jooq.impl.QOM.UCommutativeOperator;
|
||||
import org.jooq.tools.jdbc.DefaultConnection;
|
||||
|
||||
/**
|
||||
@ -315,6 +320,16 @@ final class DiagnosticsConnection extends DefaultConnection {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -361,6 +376,35 @@ final class DiagnosticsConnection extends DefaultConnection {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -158,6 +158,13 @@ final class DiagnosticsListeners implements DiagnosticsListener {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -154,6 +154,15 @@ public class LoggingDiagnosticsListener implements DiagnosticsListener {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2291,6 +2291,19 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -53,6 +53,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
// ...
|
||||
@ -139,6 +141,7 @@ import org.jooq.WindowSpecification;
|
||||
import org.jooq.XML;
|
||||
import org.jooq.XMLAttributes;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.impl.QOM.UCommutativeOperator;
|
||||
import org.jooq.types.DayToSecond;
|
||||
// ...
|
||||
|
||||
@ -8189,4 +8192,12 @@ public final class QOM {
|
||||
public static final <Q1 extends QueryPart, Q2 extends QueryPart> Tuple2<Q1, Q2> tuple(Q1 q1, Q2 q2) {
|
||||
return new TupleImpl2<>(q1, q2);
|
||||
}
|
||||
|
||||
static final <Q extends QueryPart> boolean commutativeCheck(UCommutativeOperator<Q, ?> op, Predicate<? super Q> f) {
|
||||
return f.test(op.$arg1()) || f.test(op.$arg2());
|
||||
}
|
||||
|
||||
static final <Q extends QueryPart> boolean commutativeCheck(UCommutativeOperator<Q, ?> op, BiPredicate<? super Q, ? super Q> f) {
|
||||
return f.test(op.$arg1(), op.$arg2()) || f.test(op.$arg2(), op.$arg1());
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,8 +322,17 @@ Once configured, this diagnostic is turned on by default.
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="diagnosticsConcatenationInPredicates" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether to run the {@link org.jooq.DiagnosticsListener#concatenationInPredicates(org.jooq.DiagnosticsContext) diagnostic.
|
||||
<element name="diagnosticsConcatenationInPredicate" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether to run the {@link org.jooq.DiagnosticsListener#concatenationInPredicate(org.jooq.DiagnosticsContext) diagnostic.
|
||||
<p>
|
||||
Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured.
|
||||
Once configured, this diagnostic is turned on by default.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="diagnosticsPossiblyWrongExpression" type="boolean" minOccurs="0" maxOccurs="1" default="true">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether to run the {@link org.jooq.DiagnosticsListener#possiblyWrongExpression(org.jooq.DiagnosticsContext) diagnostic.
|
||||
<p>
|
||||
Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured.
|
||||
Once configured, this diagnostic is turned on by default.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user