Search in sources :

Example 1 with SqlParser

use of org.seasar.doma.internal.jdbc.sql.SqlParser in project doma by domaframework.

the class JdbcExceptionTest method testQuotationNotClosed.

@Test
public void testQuotationNotClosed() {
    SqlParser parser = new SqlParser("select * from 'aaa");
    try {
        parser.parse();
        fail();
    } catch (JdbcException e) {
        System.out.println(e.getMessage());
        assertEquals(Message.DOMA2101, e.getMessageResource());
    }
}
Also used : SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) Test(org.junit.jupiter.api.Test)

Example 2 with SqlParser

use of org.seasar.doma.internal.jdbc.sql.SqlParser in project doma by domaframework.

the class JdbcExceptionTest method testBlockCommentNotClosed.

@Test
public void testBlockCommentNotClosed() {
    SqlParser parser = new SqlParser("select * from aaa /*aaa");
    try {
        parser.parse();
        fail();
    } catch (JdbcException e) {
        System.out.println(e.getMessage());
        assertEquals(Message.DOMA2102, e.getMessageResource());
    }
}
Also used : SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) Test(org.junit.jupiter.api.Test)

Example 3 with SqlParser

use of org.seasar.doma.internal.jdbc.sql.SqlParser in project doma by domaframework.

the class JdbcExceptionTest method testTestLiteralNotFound.

@Test
public void testTestLiteralNotFound() {
    SqlParser parser = new SqlParser("select * from aaa where bbb = /*bbb*/ 'ccc')");
    try {
        parser.parse();
        fail();
    } catch (JdbcException e) {
        System.out.println(e.getMessage());
        assertEquals(Message.DOMA2110, e.getMessageResource());
    }
}
Also used : SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) Test(org.junit.jupiter.api.Test)

Example 4 with SqlParser

use of org.seasar.doma.internal.jdbc.sql.SqlParser in project doma by domaframework.

the class JdbcExceptionTest method testIfCommentNotFoundForEndComment.

@Test
public void testIfCommentNotFoundForEndComment() {
    SqlParser parser = new SqlParser("select * from aaa/*%end*/ ");
    try {
        parser.parse();
        fail();
    } catch (JdbcException e) {
        System.out.println(e.getMessage());
        assertEquals(Message.DOMA2104, e.getMessageResource());
    }
}
Also used : SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) Test(org.junit.jupiter.api.Test)

Example 5 with SqlParser

use of org.seasar.doma.internal.jdbc.sql.SqlParser 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());
    }
}
Also used : SqlParser(org.seasar.doma.internal.jdbc.sql.SqlParser) Value(org.seasar.doma.internal.expr.Value) List(java.util.List) NodePreparedSqlBuilder(org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder) ExpressionEvaluator(org.seasar.doma.internal.expr.ExpressionEvaluator) Test(org.junit.jupiter.api.Test)

Aggregations

SqlParser (org.seasar.doma.internal.jdbc.sql.SqlParser)107 Test (org.junit.jupiter.api.Test)105 SqlNode (org.seasar.doma.jdbc.SqlNode)90 NodePreparedSqlBuilder (org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder)67 MockConfig (org.seasar.doma.internal.jdbc.mock.MockConfig)64 PreparedSql (org.seasar.doma.jdbc.PreparedSql)59 LinkedHashMap (java.util.LinkedHashMap)25 ExecutableElement (javax.lang.model.element.ExecutableElement)25 TestProcessor (org.seasar.doma.internal.apt.TestProcessor)25 List (java.util.List)7 AptException (org.seasar.doma.internal.apt.AptException)6 JdbcException (org.seasar.doma.jdbc.JdbcException)6 SelectOptions (org.seasar.doma.jdbc.SelectOptions)6 ExpressionEvaluator (org.seasar.doma.internal.expr.ExpressionEvaluator)3 Value (org.seasar.doma.internal.expr.Value)3 Iterator (java.util.Iterator)1