use of org.apache.cayenne.access.jdbc.SQLStatement in project cayenne by apache.
the class VelocitySQLTemplateProcessor_ChainTest method testProcessTemplateWithFalseOrZero1.
@Test
public void testProcessTemplateWithFalseOrZero1() throws Exception {
String template = "#chain(' OR ' 'WHERE ')" + "#chunk($a)[A]#end" + "#chunk($b)[B]#end" + "#chunk($c)$c#end" + "#end";
Map<String, Object> map = new HashMap<>();
map.put("a", false);
map.put("b", 0);
SQLStatement compiled = processor.processTemplate(template, map);
assertEquals("WHERE [A] OR [B]", compiled.getSql());
}
use of org.apache.cayenne.access.jdbc.SQLStatement in project cayenne by apache.
the class VelocitySQLTemplateProcessor_ChainTest method testProcessTemplateFullChainAndPrefix.
@Test
public void testProcessTemplateFullChainAndPrefix() throws Exception {
String template = "#chain(' OR ' 'WHERE ')" + "#chunk($a)$a#end" + "#chunk($b)$b#end" + "#chunk($c)$c#end" + "#end";
Map<String, Object> map = new HashMap<>();
map.put("a", "[A]");
map.put("b", "[B]");
map.put("c", "[C]");
SQLStatement compiled = processor.processTemplate(template, map);
assertEquals("WHERE [A] OR [B] OR [C]", compiled.getSql());
}
use of org.apache.cayenne.access.jdbc.SQLStatement in project cayenne by apache.
the class VelocitySQLTemplateProcessor_ChainTest method testProcessTemplateFullChain.
@Test
public void testProcessTemplateFullChain() throws Exception {
String template = "#chain(' OR ')" + "#chunk($a)$a#end" + "#chunk($b)$b#end" + "#chunk($c)$c#end" + "#end";
Map<String, Object> map = new HashMap<>();
map.put("a", "[A]");
map.put("b", "[B]");
map.put("c", "[C]");
SQLStatement compiled = processor.processTemplate(template, map);
assertEquals("[A] OR [B] OR [C]", compiled.getSql());
}
use of org.apache.cayenne.access.jdbc.SQLStatement in project cayenne by apache.
the class VelocitySQLTemplateProcessor_SelectTest method testProcessSelectTemplate4.
@Test
public void testProcessSelectTemplate4() throws Exception {
String sqlTemplate = "SELECT #result('A'), #result('B'), #result('C') FROM ME";
SQLStatement compiled = processor.processTemplate(sqlTemplate, Collections.<String, Object>emptyMap());
assertEquals("SELECT A, B, C FROM ME", compiled.getSql());
assertEquals(0, compiled.getBindings().length);
assertEquals(3, compiled.getResultColumns().length);
assertEquals("A", compiled.getResultColumns()[0].getName());
assertEquals("B", compiled.getResultColumns()[1].getName());
assertEquals("C", compiled.getResultColumns()[2].getName());
}
Aggregations