@Test public void testNamedDeclaredButNotProvided() { assertThatThrownBy(() -> ArgumentBinder.bind(namedParams("unused"), namedBinding(), stmt, ctx)) .isInstanceOf(UnableToCreateStatementException.class); }
static void bind(ParsedParameters parameters, Binding binding, PreparedStatement statement, StatementContext context) { if (parameters.isPositional()) { bindPositional(parameters, binding, statement, context); } else { bindNamed(parameters, binding, statement, context); } }
@Test public void testNamedNotDeclaredButProvided() { assertThatThrownBy(() -> ArgumentBinder.bind(namedParams(), namedBinding("unused"), stmt, ctx)) .isInstanceOf(UnableToCreateStatementException.class); }
static void bind(ParsedParameters parameters, Binding binding, PreparedStatement statement, StatementContext context) { if (parameters.isPositional()) { bindPositional(parameters.getParameterCount(), binding, statement, context); } else { bindNamed(parameters.getParameterNames(), binding, statement, context); } }
@Test public void testPositionalDeclaredButNotProvided() { assertThatThrownBy(() -> ArgumentBinder.bind(positionalParams(1), positionalBinding(0), stmt, ctx)) .isInstanceOf(UnableToCreateStatementException.class); }
@Test public void testPositionalNotDeclaredButProvided() { assertThatThrownBy(() -> ArgumentBinder.bind(positionalParams(0), positionalBinding(1), stmt, ctx)) .isInstanceOf(UnableToCreateStatementException.class); }
@Test public void testPositionalEmpty() { assertThatCode(() -> ArgumentBinder.bind(positionalParams(0), positionalBinding(0), stmt, ctx)) .doesNotThrowAnyException(); }
@Test public void testNamedEmpty() { assertThatCode(() -> ArgumentBinder.bind(namedParams(), namedBinding(), stmt, ctx)) .doesNotThrowAnyException(); }
@Test public void testNamedNotDeclaredButProvidedWithPermission() { allowUnused(); assertThatCode(() -> ArgumentBinder.bind(namedParams(), namedBinding("unused"), stmt, ctx)) .doesNotThrowAnyException(); }
@Test public void testPositionalNotDeclaredButProvidedWithPermission() { allowUnused(); assertThatCode(() -> ArgumentBinder.bind(positionalParams(0), positionalBinding(1), stmt, ctx)) .doesNotThrowAnyException(); }
ArgumentBinder.bind(parsedSql.getParameters(), getBinding(), stmt, ctx);
for (Binding binding : bindings) { getContext().setBinding(binding); ArgumentBinder.bind(parsedParameters, binding, stmt, getContext()); stmt.addBatch();
ArgumentBinder.bind(parsedParameters, binding, stmt, getContext()); stmt.addBatch();
ArgumentBinder.bind(parsedParameters, getBinding(), stmt, getContext());