mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-06 21:05:50 +08:00
This commit is contained in:
parent
9b2cddcf35
commit
3a83024088
@ -70,7 +70,9 @@ trait SimpleExpression[T] extends Expression[T]{
|
||||
|
||||
def notIn(right: CollectionExpression[T,_]) = in(right).not;
|
||||
|
||||
def not[M <: SimpleExpression[T]](f: (M) => BooleanExpression): BooleanExpression = f(this.asInstanceOf[M]).not();
|
||||
def is[M <: SimpleExpression[T]](f: M => BooleanExpression): BooleanExpression = if (f == null) isNull() else f(this.asInstanceOf[M]);
|
||||
|
||||
def not[M <: SimpleExpression[T]](f: M => BooleanExpression): BooleanExpression = f(this.asInstanceOf[M]).not();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,9 @@ import com.mysema.query.types._
|
||||
|
||||
object Matchers {
|
||||
|
||||
// def in[T](values: T*) = (expr: SimpleExpression[T]) => expr.in(values);
|
||||
def in[T](values: T*) = (expr: SimpleExpression[T]) => expr.in(values:_*);
|
||||
|
||||
def not(v: Void) = (expr: SimpleExpression[_]) => expr.isNotNull();
|
||||
|
||||
// map
|
||||
|
||||
|
||||
@ -14,6 +14,18 @@ class ExpressionTest {
|
||||
Assert.assertEquals(expected, actual.toString);
|
||||
}
|
||||
|
||||
@Test
|
||||
def Is_Not_Null {
|
||||
assertEquals("person.other is not null", person.other isNotNull);
|
||||
assertEquals("person.other is not null", person.other is not(null) );
|
||||
}
|
||||
|
||||
@Test
|
||||
def Is_Null {
|
||||
assertEquals("person.other is null", person.other isNull);
|
||||
assertEquals("person.other is null", person.other is null );
|
||||
}
|
||||
|
||||
@Test
|
||||
def Long_Path {
|
||||
assertEquals("person.other.firstName = Ben", person.other.firstName eq "Ben");
|
||||
@ -98,7 +110,7 @@ class ExpressionTest {
|
||||
|
||||
@Test
|
||||
def String_Or_With_Operators {
|
||||
val orClause = (person.firstName like "An%") or (person.firstName like "Be%");
|
||||
val orClause = (person.firstName like "An%") || (person.firstName like "Be%");
|
||||
assertEquals("person.firstName like An% || person.firstName like Be%", orClause);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user