Associate value with isTrue/isFalse criteria operators.
We now associate a boolean value with both operators as those operators are rendered using equals comparison in the actual SQL text. Orginal pull request #1188
This commit is contained in:
committed by
Jens Schauder
parent
c8eafe7337
commit
5352fe34cf
@@ -494,13 +494,15 @@ class QueryMapper {
|
||||
|
||||
if (comparator == Comparator.IS_TRUE) {
|
||||
|
||||
Expression bind = bindBoolean(column, parameterSource, true);
|
||||
Expression bind = bindBoolean(column, parameterSource,
|
||||
mappedValue instanceof Boolean ? (Boolean) mappedValue : true);
|
||||
return column.isEqualTo(bind);
|
||||
}
|
||||
|
||||
if (comparator == Comparator.IS_FALSE) {
|
||||
|
||||
Expression bind = bindBoolean(column, parameterSource, false);
|
||||
Expression bind = bindBoolean(column, parameterSource,
|
||||
mappedValue instanceof Boolean ? (Boolean) mappedValue : false);
|
||||
return column.isEqualTo(bind);
|
||||
}
|
||||
|
||||
|
||||
@@ -849,7 +849,7 @@ public class Criteria implements CriteriaDefinition {
|
||||
*/
|
||||
@Override
|
||||
public Criteria isTrue() {
|
||||
return createCriteria(Comparator.IS_TRUE, null);
|
||||
return createCriteria(Comparator.IS_TRUE, true);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -858,7 +858,7 @@ public class Criteria implements CriteriaDefinition {
|
||||
*/
|
||||
@Override
|
||||
public Criteria isFalse() {
|
||||
return createCriteria(Comparator.IS_FALSE, null);
|
||||
return createCriteria(Comparator.IS_FALSE, false);
|
||||
}
|
||||
|
||||
protected Criteria createCriteria(Comparator comparator, @Nullable Object value) {
|
||||
|
||||
@@ -285,6 +285,7 @@ public class CriteriaUnitTests {
|
||||
|
||||
assertThat(criteria.getColumn()).isEqualTo(SqlIdentifier.unquoted("foo"));
|
||||
assertThat(criteria.getComparator()).isEqualTo(CriteriaDefinition.Comparator.IS_TRUE);
|
||||
assertThat(criteria.getValue()).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-513
|
||||
@@ -294,5 +295,6 @@ public class CriteriaUnitTests {
|
||||
|
||||
assertThat(criteria.getColumn()).isEqualTo(SqlIdentifier.unquoted("foo"));
|
||||
assertThat(criteria.getComparator()).isEqualTo(CriteriaDefinition.Comparator.IS_FALSE);
|
||||
assertThat(criteria.getValue()).isEqualTo(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user