Search in sources :

Example 16 with SqlLocation

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

the class SqlValidator method visitValueNode.

private Void visitValueNode(ValueNode node, Void p) {
    SqlLocation location = node.getLocation();
    String variableName = node.getVariableName();
    TypeDeclaration typeDeclaration = validateExpressionVariable(location, variableName);
    if (node.getWordNode() != null) {
        if (!typeDeclaration.isScalarType()) {
            String sql = getSql(location);
            throw new AptException(Message.DOMA4153, methodElement, new Object[] { path, sql, location.getLineNumber(), location.getPosition(), variableName, typeDeclaration.getBinaryName() });
        }
    } else {
        if (!typeDeclaration.isScalarIterableType() && !typeDeclaration.isScalarArrayType()) {
            String sql = getSql(location);
            throw new AptException(Message.DOMA4161, methodElement, new Object[] { path, sql, location.getLineNumber(), location.getPosition(), variableName, typeDeclaration.getBinaryName() });
        }
    }
    visitNode(node, p);
    return null;
}
Also used : AptException(org.seasar.doma.internal.apt.AptException) SqlLocation(org.seasar.doma.internal.jdbc.sql.node.SqlLocation) TypeDeclaration(org.seasar.doma.internal.apt.decl.TypeDeclaration)

Aggregations

SqlLocation (org.seasar.doma.internal.jdbc.sql.node.SqlLocation)16 JdbcException (org.seasar.doma.jdbc.JdbcException)7 AptException (org.seasar.doma.internal.apt.AptException)6 EvaluationResult (org.seasar.doma.internal.expr.EvaluationResult)5 TypeDeclaration (org.seasar.doma.internal.apt.decl.TypeDeclaration)4 SqlNode (org.seasar.doma.jdbc.SqlNode)3 Value (org.seasar.doma.internal.expr.Value)2 ParensNode (org.seasar.doma.internal.jdbc.sql.node.ParensNode)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 ArrayType (javax.lang.model.type.ArrayType)1 DeclaredType (javax.lang.model.type.DeclaredType)1 TypeMirror (javax.lang.model.type.TypeMirror)1 FetchType (org.seasar.doma.FetchType)1 ExpressionEvaluator (org.seasar.doma.internal.expr.ExpressionEvaluator)1 BasicSingleResultHandler (org.seasar.doma.internal.jdbc.command.BasicSingleResultHandler)1