use of com.orm.androrm.statement.Statement in project androrm by androrm.
the class DeleteStatementTest method setUp.
@Override
public void setUp() {
Where where = new Where();
where.setStatement(new Statement("foo", "bar"));
mDelete = new DeleteStatement();
mDelete.from("table").where(where);
}
use of com.orm.androrm.statement.Statement 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());
}
use of com.orm.androrm.statement.Statement in project androrm by androrm.
the class OrStatementTest method testParanthesisSurrounding.
public void testParanthesisSurrounding() {
AndStatement left = new AndStatement(new Statement("foo", "bar"), new Statement("bar", "baz"));
AndStatement right = new AndStatement(new Statement("baz", "foo"), new LikeStatement("baz", "bar"));
OrStatement or = new OrStatement(left, right);
assertEquals("(foo = 'bar' AND bar = 'baz' OR baz = 'foo' AND baz LIKE '%bar%')", or.toString());
}
use of com.orm.androrm.statement.Statement in project androrm by androrm.
the class SelectStatementTest method testWhere.
public void testWhere() {
Where where = new Where();
where.setStatement(new Statement("foo", "bar"));
mSelect.where(where);
assertEquals("SELECT * FROM `table` WHERE foo = 'bar'", mSelect.toString());
}
use of com.orm.androrm.statement.Statement 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;
}
Aggregations