use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class QueryTemplateTest method generateSQLWithInClauseAndParametersAsArrayAndNeedToSplit.
@Test
public void generateSQLWithInClauseAndParametersAsArrayAndNeedToSplit() {
queryTemplate.setWhere("baz in ( ${para} )");
params.put("para", new String[] { "a", "b", "c", "d" });
query.setMaxInParameters(2);
SqlStatement sqlStatement = queryTemplate.generateSQL(query, params);
assertEquals("select foo from bar WHERE (baz in ( :para$0,:para$1 ) OR baz in ( :para$2,:para$3 ))", sqlStatement.getSql());
assertEquals(5, sqlStatement.getParameters().getValues().size());
assertArrayEquals(new String[] { "a", "b", "c", "d" }, (String[]) sqlStatement.getParameters().getValues().get("para"));
assertEquals("a", sqlStatement.getParameters().getValues().get("para$0"));
assertEquals("b", sqlStatement.getParameters().getValues().get("para$1"));
assertEquals("c", sqlStatement.getParameters().getValues().get("para$2"));
assertEquals("d", sqlStatement.getParameters().getValues().get("para$3"));
}
use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class DmlTemplateTest method generateSQLWithInClauseAndParametersAsArray.
@Test
public void generateSQLWithInClauseAndParametersAsArray() {
dmlTemplate.setWhere("baz in ( ${para} )");
params.put("para", new String[] { "a", "b" });
SqlStatement sqlStatement = dmlTemplate.generateSQL(DEFAULT_DML, params);
assertEquals("update bar set foo = :foo WHERE baz in ( :para )", sqlStatement.getSql());
assertEquals(2, sqlStatement.getParameters().getValues().size());
assertEquals(1, sqlStatement.getParameters().getValues().get("foo"));
assertArrayEquals(new String[] { "a", "b" }, (String[]) sqlStatement.getParameters().getValues().get("para"));
}
use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class QueryTemplateTest method generateSQLWithInClauseAndParametersAsArray.
@Test
public void generateSQLWithInClauseAndParametersAsArray() {
queryTemplate.setWhere("baz in ( ${para} )");
params.put("para", new String[] { "a", "b" });
SqlStatement sqlStatement = queryTemplate.generateSQL(query, params);
assertEquals("select foo from bar WHERE baz in ( :para )", sqlStatement.getSql());
assertEquals(1, sqlStatement.getParameters().getValues().size());
assertArrayEquals(new String[] { "a", "b" }, (String[]) sqlStatement.getParameters().getValues().get("para"));
}
use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class DmlTemplateTest method generateSQLWithInClause.
@Test
public void generateSQLWithInClause() {
dmlTemplate.setWhere("baz in ( a, b )");
SqlStatement sqlStatement = dmlTemplate.generateSQL(DEFAULT_DML, params);
assertEquals("update bar set foo = :foo WHERE baz in ( a, b )", sqlStatement.getSql());
assertEquals(1, sqlStatement.getParameters().getValues().size());
assertEquals(1, sqlStatement.getParameters().getValues().get("foo"));
}
use of org.jumpmind.pos.persist.SqlStatement in project openpos-framework by JumpMind.
the class DmlTemplateTest method generateSql.
@Test
public void generateSql() {
SqlStatement sqlStatement = dmlTemplate.generateSQL(DEFAULT_DML, params);
assertEquals("update bar set foo = :foo", sqlStatement.getSql());
assertEquals(1, sqlStatement.getParameters().getValues().size());
assertEquals(1, sqlStatement.getParameters().getValues().get("foo"));
}
Aggregations