use of com.orm.androrm.statement.SelectStatement in project androrm by androrm.
the class JoinStatementTest method testOnSubselect.
public void testOnSubselect() {
SelectStatement left = new SelectStatement();
left.from("left_table").select("foo");
SelectStatement right = new SelectStatement();
right.from("right_table").select("bar");
JoinStatement join = new JoinStatement();
join.left(left, "a").right(right, "b").on("foo", "bar");
assertEquals("(SELECT foo FROM `left_table`) AS a JOIN (SELECT bar FROM `right_table`) AS b ON a.foo=b.bar", join.toString());
}
use of com.orm.androrm.statement.SelectStatement in project androrm by androrm.
the class SelectStatementTest method setUp.
@Override
public void setUp() {
mSelect = new SelectStatement();
mSelect.from("table");
}
use of com.orm.androrm.statement.SelectStatement in project androrm by androrm.
the class SelectStatementTest method testFromSelect.
public void testFromSelect() {
SelectStatement select = new SelectStatement();
select.from("another_table");
mSelect.from(select);
assertEquals("SELECT * FROM (SELECT * FROM `another_table`)", mSelect.toString());
}
use of com.orm.androrm.statement.SelectStatement 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;
}
use of com.orm.androrm.statement.SelectStatement in project androrm by androrm.
the class ManyToManyField method getQuery.
private SelectStatement getQuery(int id) {
SelectStatement select = new SelectStatement();
select.select("a.*").from(getJoin("a", "b", id));
return select;
}
Aggregations