diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryColumn.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryColumn.java index 5dc7d584..a99d8f79 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryColumn.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryColumn.java @@ -399,7 +399,7 @@ public class QueryColumn implements CloneSupport, Conditional value) { - if (value == null) { + if (value == null || value.isEmpty()) { return QueryCondition.createEmpty(); } return in(value.toArray()); @@ -407,7 +407,7 @@ public class QueryColumn implements CloneSupport, Conditional value, boolean isEffective) { - if (value == null) { + if (value == null || value.isEmpty()) { return QueryCondition.createEmpty(); } return in(value.toArray()).when(isEffective); @@ -415,7 +415,7 @@ public class QueryColumn implements CloneSupport, Conditional value, BooleanSupplier isEffective) { - if (value == null) { + if (value == null || value.isEmpty()) { return QueryCondition.createEmpty(); } return in(value.toArray()).when(isEffective); @@ -423,7 +423,7 @@ public class QueryColumn implements CloneSupport, Conditional> QueryCondition in(T value, Predicate isEffective) { - if (value == null) { + if (value == null || value.isEmpty()) { return QueryCondition.createEmpty(); } return in(value.toArray()).when(isEffective.test(value)); @@ -523,7 +523,7 @@ public class QueryColumn implements CloneSupport, Conditional value) { - if (value == null) { + if (value == null || value.isEmpty()) { return QueryCondition.createEmpty(); } return notIn(value.toArray()); @@ -531,7 +531,7 @@ public class QueryColumn implements CloneSupport, Conditional value, boolean isEffective) { - if (value == null) { + if (value == null || value.isEmpty()) { return QueryCondition.createEmpty(); } return notIn(value.toArray()).when(isEffective); @@ -539,7 +539,7 @@ public class QueryColumn implements CloneSupport, Conditional value, BooleanSupplier isEffective) { - if (value == null) { + if (value == null || value.isEmpty()) { return QueryCondition.createEmpty(); } return notIn(value.toArray()).when(isEffective); @@ -547,7 +547,7 @@ public class QueryColumn implements CloneSupport, Conditional> QueryCondition notIn(T value, Predicate isEffective) { - if (value == null) { + if (value == null || value.isEmpty()) { return QueryCondition.createEmpty(); } return notIn(value.toArray()).when(isEffective.test(value)); @@ -579,41 +579,65 @@ public class QueryColumn implements CloneSupport, Conditional QueryCondition between(S start, E end, BiPredicate isEffective) { + if (QueryColumnBehavior.shouldIgnoreValue(start) || QueryColumnBehavior.shouldIgnoreValue(end)) { + return QueryCondition.createEmpty(); + } return QueryCondition.create(this, SqlOperator.BETWEEN, new Object[]{start, end}).when(isEffective.test(start, end)); } @Override public QueryCondition notBetween(Object start, Object end) { + if (QueryColumnBehavior.shouldIgnoreValue(start) || QueryColumnBehavior.shouldIgnoreValue(end)) { + return QueryCondition.createEmpty(); + } return QueryCondition.create(this, SqlOperator.NOT_BETWEEN, new Object[]{start, end}); } @Override public QueryCondition notBetween(Object start, Object end, boolean isEffective) { + if (QueryColumnBehavior.shouldIgnoreValue(start) || QueryColumnBehavior.shouldIgnoreValue(end)) { + return QueryCondition.createEmpty(); + } return QueryCondition.create(this, SqlOperator.NOT_BETWEEN, new Object[]{start, end}).when(isEffective); } @Override public QueryCondition notBetween(Object start, Object end, BooleanSupplier isEffective) { + if (QueryColumnBehavior.shouldIgnoreValue(start) || QueryColumnBehavior.shouldIgnoreValue(end)) { + return QueryCondition.createEmpty(); + } return QueryCondition.create(this, SqlOperator.NOT_BETWEEN, new Object[]{start, end}).when(isEffective); } @Override public QueryCondition notBetween(S start, E end, BiPredicate isEffective) { + if (QueryColumnBehavior.shouldIgnoreValue(start) || QueryColumnBehavior.shouldIgnoreValue(end)) { + return QueryCondition.createEmpty(); + } return QueryCondition.create(this, SqlOperator.NOT_BETWEEN, new Object[]{start, end}).when(isEffective.test(start, end)); } @@ -717,6 +741,9 @@ public class QueryColumn implements CloneSupport, Conditional, Conditional, Conditional QueryCondition likeRaw(T value, Predicate isEffective) { + if (QueryColumnBehavior.shouldIgnoreValue(value)) { + return QueryCondition.createEmpty(); + } return likeRaw(value, isEffective.test(value)); } @@ -844,6 +877,9 @@ public class QueryColumn implements CloneSupport, Conditional, Conditional, Conditional QueryCondition notLikeRaw(T value, Predicate isEffective) { + if (QueryColumnBehavior.shouldIgnoreValue(value)) { + return QueryCondition.createEmpty(); + } return likeRaw(value, isEffective.test(value)); }