use of org.seasar.doma.internal.jdbc.sql.SqlParser in project doma by domaframework.
the class Mssql2008ForUpdateTransformerTest method testForUpdateNormal.
@Test
public void testForUpdateNormal() {
String expected = "select * from emp with (updlock, rowlock) order by emp.id";
Mssql2008ForUpdateTransformer transformer = new Mssql2008ForUpdateTransformer(SelectForUpdateType.NORMAL, 0);
SqlParser parser = new SqlParser("select * 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.SqlParser in project doma by domaframework.
the class Mssql2008ForUpdateTransformerTest method testForUpdateNowait.
@Test
public void testForUpdateNowait() {
String expected = "select * from emp with (updlock, rowlock, nowait) order by emp.id";
Mssql2008ForUpdateTransformer transformer = new Mssql2008ForUpdateTransformer(SelectForUpdateType.NOWAIT, 0);
SqlParser parser = new SqlParser("select * 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.SqlParser in project doma by domaframework.
the class SqlValidatorTest method testLiteralVariable_list.
@Test
void testLiteralVariable_list() throws Exception {
Class<?> target = SqlValidationDao.class;
addCompilationUnit(target);
addProcessor(new TestProcessor() {
@Override
protected void run() {
ExecutableElement methodElement = createMethodElement(target, "testBindVariable_list", List.class);
LinkedHashMap<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
SqlValidator validator = new SqlValidator(ctx, methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql", false, false);
SqlParser parser = new SqlParser("select * from emp where name in /*^ names */('aaa')");
SqlNode sqlNode = parser.parse();
sqlNode.accept(validator, null);
}
});
compile();
assertTrue(getCompiledResult());
}
use of org.seasar.doma.internal.jdbc.sql.SqlParser in project doma by domaframework.
the class SqlValidatorTest method testLiteralVariable_array.
@Test
void testLiteralVariable_array() throws Exception {
Class<?> target = SqlValidationDao.class;
addCompilationUnit(target);
addProcessor(new TestProcessor() {
@Override
protected void run() {
ExecutableElement methodElement = createMethodElement(target, "testBindVariable_array", String[].class);
LinkedHashMap<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
SqlValidator validator = new SqlValidator(ctx, methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql", false, false);
SqlParser parser = new SqlParser("select * from emp where name in /*^ names */('aaa')");
SqlNode sqlNode = parser.parse();
sqlNode.accept(validator, null);
}
});
compile();
assertTrue(getCompiledResult());
}
use of org.seasar.doma.internal.jdbc.sql.SqlParser in project doma by domaframework.
the class SqlValidatorTest method testFor_array.
@Test
void testFor_array() throws Exception {
Class<?> target = SqlValidationDao.class;
addCompilationUnit(target);
addProcessor(new TestProcessor() {
@Override
protected void run() {
ExecutableElement methodElement = createMethodElement(target, "testFor_array", String[].class);
LinkedHashMap<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
SqlValidator validator = new SqlValidator(ctx, methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql", false, false);
SqlParser parser = new SqlParser("select * from emp where name = /*%for e : names*/ /*e*/'aaa' /*%if e_has_next*/or/*%end*//*%end*/");
SqlNode sqlNode = parser.parse();
sqlNode.accept(validator, null);
}
});
compile();
assertTrue(getCompiledResult());
}
Aggregations