use of org.seasar.doma.jdbc.SqlNode in project doma by domaframework.
the class SqlParserTest method testParens_removeAnd.
@Test
public void testParens_removeAnd() {
ExpressionEvaluator evaluator = new ExpressionEvaluator();
evaluator.add("name", new Value(String.class, null));
String testSql = "select * from aaa where (\n/*%if name != null*/bbb = /*name*/'ccc'\n/*%else*/\nand ddd is null\n /*%end*/)";
SqlParser parser = new SqlParser(testSql);
SqlNode sqlNode = parser.parse();
PreparedSql sql = new NodePreparedSqlBuilder(config, SqlKind.SELECT, "dummyPath", evaluator, SqlLogType.FORMATTED).build(sqlNode, Function.identity());
assertEquals("select * from aaa where (\n\n ddd is null\n )", sql.getRawSql());
assertEquals("select * from aaa where (\n\n ddd is null\n )", sql.getFormattedSql());
assertEquals(0, sql.getParameters().size());
}
use of org.seasar.doma.jdbc.SqlNode in project doma by domaframework.
the class SqlParserTest method testEmptyParens_whiteSpace.
@Test
public void testEmptyParens_whiteSpace() {
ExpressionEvaluator evaluator = new ExpressionEvaluator();
SqlParser parser = new SqlParser("select rank( )");
SqlNode sqlNode = parser.parse();
PreparedSql sql = new NodePreparedSqlBuilder(config, SqlKind.SELECT, "dummyPath", evaluator, SqlLogType.FORMATTED).build(sqlNode, Function.identity());
assertEquals("select rank( )", sql.getRawSql());
}
use of org.seasar.doma.jdbc.SqlNode in project doma by domaframework.
the class SqlParserTest method testBindVariable_booleanFalseLiteral.
@Test
public void testBindVariable_booleanFalseLiteral() {
String testSql = "select * from aaa where ename = /*name*/false";
SqlParser parser = new SqlParser(testSql);
SqlNode node = parser.parse();
assertNotNull(node);
}
use of org.seasar.doma.jdbc.SqlNode in project doma by domaframework.
the class SqlParserTest method testIf_removeWhere.
@Test
public void testIf_removeWhere() {
ExpressionEvaluator evaluator = new ExpressionEvaluator();
evaluator.add("name", new Value(String.class, null));
String testSql = "select * from aaa where /*%if name != null*/bbb = /*name*/'ccc' /*%end*/";
SqlParser parser = new SqlParser(testSql);
SqlNode sqlNode = parser.parse();
PreparedSql sql = new NodePreparedSqlBuilder(config, SqlKind.SELECT, "dummyPath", evaluator, SqlLogType.FORMATTED).build(sqlNode, Function.identity());
assertEquals("select * from aaa", sql.getRawSql());
assertEquals("select * from aaa", sql.getFormattedSql());
assertEquals(0, sql.getParameters().size());
}
use of org.seasar.doma.jdbc.SqlNode in project doma by domaframework.
the class SqlParserTest method testBindVariable_in_empty_iterable.
@Test
public void testBindVariable_in_empty_iterable() {
ExpressionEvaluator evaluator = new ExpressionEvaluator();
evaluator.add("name", new Value(List.class, Collections.emptyList()));
String testSql = "select * from aaa where ename in /*name*/('aaa', 'bbb')";
SqlParser parser = new SqlParser(testSql);
SqlNode sqlNode = parser.parse();
PreparedSql sql = new NodePreparedSqlBuilder(config, SqlKind.SELECT, "dummyPath", evaluator, SqlLogType.FORMATTED).build(sqlNode, Function.identity());
assertEquals("select * from aaa where ename in (null)", sql.getRawSql());
assertEquals("select * from aaa where ename in (null)", sql.getFormattedSql());
assertEquals(0, sql.getParameters().size());
}
Aggregations