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);
}
}
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());
}
}
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());
}
}
Aggregations