Search in sources :

Example 1 with LikeStatement

use of com.orm.androrm.statement.LikeStatement in project androrm by androrm.

the class FilterTest method testContains.

public void testContains() {
    Filter set = new Filter();
    set.contains("supplier__name", "foo");
    List<Rule> filters = set.getRules();
    Rule filter = filters.get(0);
    Statement s = filter.getStatement();
    Set<String> keys = s.getKeys();
    assertEquals("supplier__name", filter.getKey());
    assertTrue(keys.contains("name"));
    assertTrue(s instanceof LikeStatement);
    assertEquals("name LIKE '%foo%'", s.toString());
}
Also used : LikeStatement(com.orm.androrm.statement.LikeStatement) Filter(com.orm.androrm.Filter) InStatement(com.orm.androrm.statement.InStatement) Statement(com.orm.androrm.statement.Statement) LikeStatement(com.orm.androrm.statement.LikeStatement) Rule(com.orm.androrm.Rule)

Example 2 with LikeStatement

use of com.orm.androrm.statement.LikeStatement in project androrm by androrm.

the class LikeStatementTest method testMatchBeginning.

public void testMatchBeginning() {
    LikeStatement like = new LikeStatement("^foo", "bar");
    assertEquals("foo LIKE 'bar%'", like.toString());
}
Also used : LikeStatement(com.orm.androrm.statement.LikeStatement)

Example 3 with LikeStatement

use of com.orm.androrm.statement.LikeStatement in project androrm by androrm.

the class LikeStatementTest method testPlainStatement.

public void testPlainStatement() {
    LikeStatement like = new LikeStatement("foo", "bar");
    assertEquals("foo LIKE '%bar%'", like.toString());
}
Also used : LikeStatement(com.orm.androrm.statement.LikeStatement)

Example 4 with LikeStatement

use of com.orm.androrm.statement.LikeStatement in project androrm by androrm.

the class LikeStatementTest method testGetKeys.

public void testGetKeys() {
    LikeStatement like = new LikeStatement("foo", "bar");
    Set<String> keys = like.getKeys();
    assertEquals(1, keys.size());
    assertTrue(keys.contains("foo"));
}
Also used : LikeStatement(com.orm.androrm.statement.LikeStatement)

Example 5 with LikeStatement

use of com.orm.androrm.statement.LikeStatement in project androrm by androrm.

the class OrStatementTest method testParanthesis.

public void testParanthesis() {
    OrStatement left = new OrStatement(new Statement("foo", "bar"), new Statement("bar", "baz"));
    OrStatement right = new OrStatement(new Statement("baz", "foo"), new LikeStatement("baz", "bar"));
    AndStatement and = new AndStatement(left, right);
    assertEquals("(foo = 'bar' OR bar = 'baz') AND (baz = 'foo' OR baz LIKE '%bar%')", and.toString());
}
Also used : AndStatement(com.orm.androrm.statement.AndStatement) LikeStatement(com.orm.androrm.statement.LikeStatement) OrStatement(com.orm.androrm.statement.OrStatement) AndStatement(com.orm.androrm.statement.AndStatement) LikeStatement(com.orm.androrm.statement.LikeStatement) Statement(com.orm.androrm.statement.Statement) OrStatement(com.orm.androrm.statement.OrStatement)

Aggregations

LikeStatement (com.orm.androrm.statement.LikeStatement)6 Statement (com.orm.androrm.statement.Statement)3 AndStatement (com.orm.androrm.statement.AndStatement)2 OrStatement (com.orm.androrm.statement.OrStatement)2 Filter (com.orm.androrm.Filter)1 Rule (com.orm.androrm.Rule)1 InStatement (com.orm.androrm.statement.InStatement)1