use of org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder in project doma by domaframework.
the class JdbcExceptionTest method testCollectionOfBindValueContainsNull.
@Test
public void testCollectionOfBindValueContainsNull() {
SqlParser parser = new SqlParser("select * from aaa where bbb in /*bbb*/(1,2,3)");
SqlNode sqlNode = parser.parse();
ExpressionEvaluator evaluator = new ExpressionEvaluator();
evaluator.add("bbb", new Value(List.class, Arrays.asList(1, null)));
NodePreparedSqlBuilder builder = new NodePreparedSqlBuilder(config, SqlKind.SELECT, "dummyPath", evaluator, SqlLogType.FORMATTED);
try {
builder.build(sqlNode, Function.identity());
fail();
} catch (JdbcException e) {
System.out.println(e.getMessage());
assertEquals(Message.DOMA2115, e.getMessageResource());
}
}
use of org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder in project doma by domaframework.
the class StandardPagingTransformerTest method testOffsetLimit_forNode.
@Test
public void testOffsetLimit_forNode() {
String expected = "select * from ( select temp_.*, row_number() over( order by temp_.name1, temp_.name2, temp_.id ) as doma_rownumber_ from ( select emp.id from emp ) as temp_ ) as temp2_ where doma_rownumber_ > 5 and doma_rownumber_ <= 15";
StandardPagingTransformer transformer = new StandardPagingTransformer(5, 10);
SqlParser parser = new SqlParser("select emp.id from emp order by /*%for e: values*/emp.name/*#e*/, /*%end*/emp.id");
SqlNode sqlNode = transformer.transform(parser.parse());
ExpressionEvaluator evaluator = new ExpressionEvaluator();
evaluator.add("values", new Value(List.class, Arrays.asList(1, 2)));
NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath", evaluator, SqlLogType.FORMATTED);
PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity());
assertEquals(expected, sql.getRawSql());
}
use of org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder in project doma by domaframework.
the class StandardPagingTransformerTest method testOffsetLimit.
@Test
public void testOffsetLimit() {
String expected = "select * from ( select temp_.*, row_number() over( order by temp_.id ) as doma_rownumber_ from ( select emp.id from emp ) as temp_ ) as temp2_ where doma_rownumber_ > 5 and doma_rownumber_ <= 15";
StandardPagingTransformer transformer = new StandardPagingTransformer(5, 10);
SqlParser parser = new SqlParser("select emp.id from emp order by emp.id");
SqlNode sqlNode = transformer.transform(parser.parse());
NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath");
PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity());
assertEquals(expected, sql.getRawSql());
}
use of org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder in project doma by domaframework.
the class SqlFileModifyQuery method prepareSql.
protected void prepareSql() {
SqlFile sqlFile = config.getSqlFileRepository().getSqlFile(method, sqlFilePath, config.getDialect());
ExpressionEvaluator evaluator = new ExpressionEvaluator(parameters, config.getDialect().getExpressionFunctions(), config.getClassHelper());
NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(config, kind, sqlFile.getPath(), evaluator, sqlLogType, this::expandColumns, this::populateValues);
sql = sqlBuilder.build(sqlFile.getSqlNode(), this::comment);
}
use of org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder in project doma by domaframework.
the class SqlFileSelectQuery method prepareSql.
protected void prepareSql() {
sqlFile = config.getSqlFileRepository().getSqlFile(method, sqlFilePath, config.getDialect());
SqlNode transformedSqlNode = config.getDialect().transformSelectSqlNode(sqlFile.getSqlNode(), options);
buildSql((evaluator, expander) -> {
NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(config, SqlKind.SELECT, sqlFilePath, evaluator, sqlLogType, expander);
return sqlBuilder.build(transformedSqlNode, this::comment);
});
}
Aggregations