use of org.dbflute.twowaysql.exception.EmbeddedVariableCommentInScopeNotListException 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);
}
}
use of org.dbflute.twowaysql.exception.EmbeddedVariableCommentInScopeNotListException in project dbflute-core by dbflute.
the class EmbeddedVariableNodeTest 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 (EmbeddedVariableCommentInScopeNotListException e) {
// OK
log(e.getMessage());
}
}
Aggregations