Search in sources :

Example 1 with EmbeddedVariableCommentContainsBindSymbolException

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

the class EmbeddedVariableNode method assertNotContainBindSymbol.

protected void assertNotContainBindSymbol(String value) {
    if (_overlookNativeBinding) {
        // for general purpose e.g. MailFlute (to avoid question mark headache)
        return;
    }
    if (containsBindSymbol(value)) {
        final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
        br.addNotice("The value of embedded comment contained bind symbols.");
        br.addItem("Advice");
        br.addElement("The value of embedded comment should not contain bind symbols.");
        br.addElement("For example, a question mark '?'.");
        br.addItem("Comment Expression");
        br.addElement(_expression);
        br.addItem("Embedded Value");
        br.addElement(value);
        final String msg = br.buildExceptionMessage();
        throw new EmbeddedVariableCommentContainsBindSymbolException(msg);
    }
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) EmbeddedVariableCommentContainsBindSymbolException(org.dbflute.twowaysql.exception.EmbeddedVariableCommentContainsBindSymbolException)

Example 2 with EmbeddedVariableCommentContainsBindSymbolException

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

the class EmbeddedVariableNodeTest method test_accept_inScope_bindSymbol.

public void test_accept_inScope_bindSymbol() {
    // ## Arrange ##
    String sql = "in /*$pmb.memberNameList*/('foo', 'bar')";
    SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
    Node rootNode = analyzer.analyze();
    MockMemberPmb pmb = new MockMemberPmb();
    pmb.setMemberNameList(DfCollectionUtil.newArrayList("baz", "q?ux"));
    CommandContext ctx = createCtx(pmb);
    // ## Act ##
    try {
        rootNode.accept(ctx);
        // ## Assert ##
        fail();
    } catch (EmbeddedVariableCommentContainsBindSymbolException e) {
        // OK
        log(e.getMessage());
    }
}
Also used : CommandContext(org.dbflute.twowaysql.context.CommandContext) EmbeddedVariableCommentContainsBindSymbolException(org.dbflute.twowaysql.exception.EmbeddedVariableCommentContainsBindSymbolException) SqlAnalyzer(org.dbflute.twowaysql.SqlAnalyzer)

Example 3 with EmbeddedVariableCommentContainsBindSymbolException

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

the class EmbeddedVariableNodeTest method test_accept_contains_bindSymbol.

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

Aggregations

EmbeddedVariableCommentContainsBindSymbolException (org.dbflute.twowaysql.exception.EmbeddedVariableCommentContainsBindSymbolException)3 SqlAnalyzer (org.dbflute.twowaysql.SqlAnalyzer)2 CommandContext (org.dbflute.twowaysql.context.CommandContext)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1