public void testWhere() {
{
Boy b = new Boy();
b.id = 1;
b.girlId = 2;
DbSqlBuilder dbc = sql().match("Boy", b)._(" ").table(b, null);
assertEquals("(BOY.GIRL_ID=:boy.girlId and BOY.ID=:boy.id) BOY", dbc.generateQuery());
dbc = sql().match("b", b)._(" ").table(b, "b");
assertEquals("(b.GIRL_ID=:boy.girlId and b.ID=:boy.id) BOY b", dbc.generateQuery());
}
{
BadBoy bb = new BadBoy();
DbSqlBuilder dbc = sql().match("BadBoy", bb).table(bb, null);
assertEquals("(1=1) BOY", dbc.generateQuery());
dbc = sql().match("b", bb).table(bb, "b");
assertEquals("(1=1) BOY b", dbc.generateQuery());
}
{
BadBoy bb = new BadBoy();
DbSqlBuilder dbc = sql()._("where ").match("BadBoy", bb)._(" ").table(bb, null);
assertEquals("where (1=1) BOY", dbc.generateQuery());
dbc = sql()._("where")._().match("b", bb)._(" ").table(bb, "b");
assertEquals("where (1=1) BOY b", dbc.generateQuery());
dbc = sql()._("where")._().match("BadBoy", bb).table(bb, null);
assertEquals("where (1=1) BOY", dbc.generateQuery());
dbc = sql()._("where ").match("b", bb).table(bb, "b");
assertEquals("where (1=1) BOY b", dbc.generateQuery());
bb.ajdi = Integer.valueOf(3);
dbc = sql()._("where ").match("BadBoy", bb)._(" ").table(bb, null);
assertEquals("where (BOY.ID=:badBoy.ajdi) BOY", dbc.generateQuery());
dbc = sql()._("where ").match("b", bb)._(" ").table(bb, "b");
assertEquals("where (b.ID=:badBoy.ajdi) BOY b", dbc.generateQuery());
bb.ajdi = null;
bb.nejm = "";
dbc = sql()._("where ").match("BadBoy", bb)._(" ").table(bb, null);
assertEquals("where (1=1) BOY", dbc.generateQuery());
dbc = sql()._("where ").match("b", bb)._(" ").table(bb, "b");
assertEquals("where (1=1) BOY b", dbc.generateQuery());
bb.ajdi = null;
bb.nejm = "foo";
dbc = sql()._("where ").match("BadBoy", bb)._(" ").table(bb, null);
assertEquals("where (BOY.NAME=:badBoy.nejm) BOY", dbc.generateQuery());
dbc = sql()._("where ").match("b", bb)._(" ").table(bb, "b");
assertEquals("where (b.NAME=:badBoy.nejm) BOY b", dbc.generateQuery());
}
}