use of com.developmentontheedge.sql.model.AstSelect in project be5 by DevelopmentOnTheEdge.
the class AstTest method selectWhereEmpty.
@Test
public void selectWhereEmpty() {
Map<String, ? super Object> name = new HashMap<>();
AstSelect users = Ast.selectCount().from("users").where(name);
assertEquals("SELECT COUNT(*) AS \"count\" FROM users", users.format());
}
use of com.developmentontheedge.sql.model.AstSelect in project be5 by DevelopmentOnTheEdge.
the class AstTest method selectWhere2.
@Test
public void selectWhere2() {
Map<String, ? super Object> names = new HashMap<>();
names.put("name", "test");
names.put("name2", "test2");
AstSelect users = Ast.selectCount().from("users").where(names);
assertEquals("SELECT COUNT(*) AS \"count\" FROM users WHERE name =? AND name2 =?", users.format());
}
use of com.developmentontheedge.sql.model.AstSelect in project be5 by DevelopmentOnTheEdge.
the class AstTest method selectWhereNotNull.
/**
* todo можно сделать какой-нибудь хак (ID IS NULL OR ( null = ? ) )
*/
@Test
@Ignore
public void selectWhereNotNull() {
Map<String, ? super Object> names = new HashMap<>();
names.put("name", "null");
AstSelect users = Ast.selectCount().from("users").where(names);
assertEquals("SELECT COUNT(*) AS \"count\" FROM users WHERE name IS NULL", users.format());
names.clear();
names.put("name", "notNull");
AstSelect users2 = Ast.selectCount().from("users").where(names);
assertEquals("SELECT COUNT(*) AS \"count\" FROM users WHERE name IS NOT NULL", users2.format());
}
use of com.developmentontheedge.sql.model.AstSelect in project be5 by DevelopmentOnTheEdge.
the class AstTest method selectAll.
@Test
public void selectAll() {
AstSelect users = Ast.selectAll().from("users");
assertEquals("SELECT * FROM users", users.format());
}
use of com.developmentontheedge.sql.model.AstSelect in project be5 by DevelopmentOnTheEdge.
the class ProvincesRepository method findAll.
@Override
public Iterable<Provinces> findAll(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Provinces.class) Closure conditions) {
Map<String, Object> conditionsMap = toMap(conditions);
AstSelect sql = Ast.selectAll().from(entityName).where(conditionsMap);
return db.query(sql.format(), beanListHandler, conditionsMap.values().toArray());
}
Aggregations