mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
This commit is contained in:
parent
4c9f689467
commit
bd2a65e947
@ -6,8 +6,4 @@ not expansion for
|
||||
contains
|
||||
containsKey
|
||||
containsValue
|
||||
like
|
||||
matches
|
||||
startsWith
|
||||
endsWith
|
||||
contains
|
||||
|
||||
@ -417,9 +417,38 @@ trait StringExpression extends ComparableExpression[String] {
|
||||
override def as(right: Path[String]) = string(ALIAS.asInstanceOf[Operator[String]], this, right);
|
||||
|
||||
override def as(alias: String): StringExpression = as(new PathImpl[String](getType, alias));
|
||||
|
||||
def not() = new StringNegations(this)
|
||||
|
||||
}
|
||||
|
||||
// NOTE : experimental
|
||||
class StringNegations (val str: StringExpression) {
|
||||
|
||||
def like(right: String): BooleanExpression = str.like(right).not;
|
||||
|
||||
def like(right: Expression[String]) = str.like(right).not;
|
||||
|
||||
def matches(right: String) = str.matches(right).not;
|
||||
|
||||
def matches(right: Expression[String]) = str.matches(right).not;
|
||||
|
||||
def contains(right: String) = str.contains(right).not;
|
||||
|
||||
def contains(right: Expression[String]) = str.contains(right).not;
|
||||
|
||||
def startsWith(right: String) = str.startsWith(right).not;
|
||||
|
||||
def startsWith(right: Expression[String]) = str.startsWith(right).not;
|
||||
|
||||
def endsWith(right: String) = str.endsWith(right).not;
|
||||
|
||||
def endsWith(right: Expression[String]) = str.endsWith(right).not;
|
||||
|
||||
def empty = str.isNotEmpty;
|
||||
|
||||
}
|
||||
|
||||
trait TemporalExpression[T <: Comparable[_]] extends ComparableExpression[T] {
|
||||
|
||||
def after(right: T) = gt(right);
|
||||
|
||||
@ -295,6 +295,15 @@ class ExpressionTest {
|
||||
assertEquals("endsWith(person.firstName,amin)", person.firstName endsWith "amin");
|
||||
}
|
||||
|
||||
@Test
|
||||
def String_Negations {
|
||||
assertEquals("!person.firstName like XXX", person.firstName not() like "XXX"); // FIXME
|
||||
assertEquals("!matches(person.firstName,XXX)", person.firstName not() matches "XXX"); // FIXME
|
||||
assertEquals("!startsWith(person.firstName,XXX)", person.firstName not() startsWith"XXX"); // FIXME
|
||||
assertEquals("!endsWith(person.firstName,XXX)", person.firstName not() endsWith "XXX"); // FIXME
|
||||
assertEquals("!empty(person.firstName)", person.firstName not() empty); // FIXME
|
||||
}
|
||||
|
||||
// @Test
|
||||
// def Prefix(){
|
||||
// assertEquals("count(person)", count(person));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user