[#3205] Add DSL.condition(Boolean) as a convenience for condition(Field<Boolean>)
This commit is contained in:
parent
9175818369
commit
44fc9fd1f7
@ -583,6 +583,9 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
not(true),
|
||||
not(false),
|
||||
not((Boolean) null),
|
||||
field(not(condition(true))),
|
||||
field(not(condition(false))),
|
||||
field(not(condition((Boolean) null))),
|
||||
field(not(condition(val(true)))),
|
||||
field(not(condition(val(false)))),
|
||||
field(not(condition(val(null, Boolean.class))))
|
||||
@ -595,6 +598,9 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
assertEquals(false, record.getValue(3));
|
||||
assertEquals(true, record.getValue(4));
|
||||
assertEquals(null, record.getValue(5));
|
||||
assertEquals(false, record.getValue(6));
|
||||
assertEquals(true, record.getValue(7));
|
||||
assertEquals(null, record.getValue(8));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -5892,6 +5892,25 @@ public class DSL {
|
||||
return new SQLCondition(queryPart(template, parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a condition from a boolean field.
|
||||
* <p>
|
||||
* Databases that support boolean data types can use boolean expressions
|
||||
* as predicates or as columns interchangeably. This extends to any type
|
||||
* of field, including functions. A Postgres example:
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* select 1 where texteq('a', 'a');
|
||||
* </pre></code>
|
||||
*
|
||||
* @param value The boolean expression.
|
||||
* @return A condition wrapping the boolean expression
|
||||
*/
|
||||
@Support
|
||||
public static Condition condition(Boolean value) {
|
||||
return condition(Utils.field(value, Boolean.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a condition from a boolean field.
|
||||
* <p>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user