Search in sources :

Example 1 with Where

use of com.orm.androrm.Where in project androrm by androrm.

the class WhereTest method testSimpleConstraint.

public void testSimpleConstraint() {
    Where where = new Where();
    where.and("foo", "bar");
    assertEquals(" WHERE foo = 'bar'", where.toString());
    where = new Where();
    where.or("foo", "bar");
    assertEquals(" WHERE foo = 'bar'", where.toString());
}
Also used : Where(com.orm.androrm.Where)

Example 2 with Where

use of com.orm.androrm.Where in project androrm by androrm.

the class WhereTest method testEmptyWhere.

public void testEmptyWhere() {
    Where where = new Where();
    assertNull(where.toString());
}
Also used : Where(com.orm.androrm.Where)

Example 3 with Where

use of com.orm.androrm.Where in project androrm by androrm.

the class WhereTest method testAddOr.

public void testAddOr() {
    Where where = new Where();
    where.or("foo", "bar").or("bar", "baz");
    assertEquals(" WHERE (foo = 'bar' OR bar = 'baz')", where.toString());
}
Also used : Where(com.orm.androrm.Where)

Example 4 with Where

use of com.orm.androrm.Where in project androrm by androrm.

the class WhereTest method testAddAnd.

public void testAddAnd() {
    Where where = new Where();
    where.and("foo", "bar").and("bar", "baz");
    assertEquals(" WHERE foo = 'bar' AND bar = 'baz'", where.toString());
}
Also used : Where(com.orm.androrm.Where)

Example 5 with Where

use of com.orm.androrm.Where in project androrm by androrm.

the class ManyToManyField method getRightJoinSide.

private SelectStatement getRightJoinSide(int id) {
    String leftTable = DatabaseBuilder.getTableName(mOriginClass);
    String rightTable = DatabaseBuilder.getTableName(mTargetClass);
    Where where = new Where();
    where.setStatement(new Statement(leftTable, id));
    SelectStatement relation = new SelectStatement();
    relation.from(mTableName).select(leftTable, rightTable).where(where);
    JoinStatement join = new JoinStatement();
    join.left(relation, "left").right(rightTable, "right").on(rightTable, Model.PK);
    SelectStatement select = new SelectStatement();
    select.from(join).select("left." + rightTable + " AS " + rightTable);
    return select;
}
Also used : SelectStatement(com.orm.androrm.statement.SelectStatement) JoinStatement(com.orm.androrm.statement.JoinStatement) SelectStatement(com.orm.androrm.statement.SelectStatement) Statement(com.orm.androrm.statement.Statement) Where(com.orm.androrm.Where) JoinStatement(com.orm.androrm.statement.JoinStatement)

Aggregations

Where (com.orm.androrm.Where)8 Statement (com.orm.androrm.statement.Statement)3 JoinStatement (com.orm.androrm.statement.JoinStatement)2 SelectStatement (com.orm.androrm.statement.SelectStatement)2 DeleteStatement (com.orm.androrm.statement.DeleteStatement)1