Search in sources :

Example 1 with BindVariableCommentInScopeNotListException

use of org.dbflute.twowaysql.exception.BindVariableCommentInScopeNotListException in project dbflute-core by dbflute.

the class BindVariableNodeTest method test_accept_inScope_notList.

public void test_accept_inScope_notList() {
    // ## Arrange ##
    String sql = "in /*pmb.memberName*/('foo', 'bar')";
    SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
    Node rootNode = analyzer.analyze();
    MockMemberPmb pmb = new MockMemberPmb();
    pmb.setMemberName("foo");
    CommandContext ctx = createCtx(pmb);
    // ## Act ##
    try {
        rootNode.accept(ctx);
        // ## Assert ##
        fail();
    } catch (BindVariableCommentInScopeNotListException e) {
        // OK
        log(e.getMessage());
    }
}
Also used : BindVariableCommentInScopeNotListException(org.dbflute.twowaysql.exception.BindVariableCommentInScopeNotListException) CommandContext(org.dbflute.twowaysql.context.CommandContext) SqlAnalyzer(org.dbflute.twowaysql.SqlAnalyzer)

Example 2 with BindVariableCommentInScopeNotListException

use of org.dbflute.twowaysql.exception.BindVariableCommentInScopeNotListException in project dbflute-core by dbflute.

the class NodeChecker method throwBindOrEmbeddedCommentInScopeNotListException.

public static void throwBindOrEmbeddedCommentInScopeNotListException(String expression, Class<?> targetType, String specifiedSql, boolean bind) {
    final String emmark = (bind ? "" : "$");
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The parameter for in-scope condition was not list or array.");
    br.addItem("Advice");
    br.addElement("If a style of a test value is, e.g. (2, 5, 7)',");
    br.addElement("the parameter should be list (collection) or array for in-scope.");
    br.addElement("For example:");
    br.addElement("  (x) - MEMBER_ID in /*" + emmark + "pmb.memberId*/('foo', 'bar')");
    br.addElement("  (o) - MEMBER_ID in /*" + emmark + "pmb.memberIdList*/('foo', 'bar')");
    br.addItem("Comment Expression");
    br.addElement(expression);
    br.addItem("Parameter Type");
    br.addElement(targetType);
    br.addItem("Specified SQL");
    br.addElement(specifiedSql);
    final String msg = br.buildExceptionMessage();
    if (bind) {
        throw new BindVariableCommentInScopeNotListException(msg);
    } else {
        throw new EmbeddedVariableCommentInScopeNotListException(msg);
    }
}
Also used : BindVariableCommentInScopeNotListException(org.dbflute.twowaysql.exception.BindVariableCommentInScopeNotListException) EmbeddedVariableCommentInScopeNotListException(org.dbflute.twowaysql.exception.EmbeddedVariableCommentInScopeNotListException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder)

Aggregations

BindVariableCommentInScopeNotListException (org.dbflute.twowaysql.exception.BindVariableCommentInScopeNotListException)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 SqlAnalyzer (org.dbflute.twowaysql.SqlAnalyzer)1 CommandContext (org.dbflute.twowaysql.context.CommandContext)1 EmbeddedVariableCommentInScopeNotListException (org.dbflute.twowaysql.exception.EmbeddedVariableCommentInScopeNotListException)1