Browse Source

Introduce @⁠Disabled failing test for R2DBC NamedParameterUtils

The last assertion of the new test method currently fails since "foo"
is only bound once.

java.lang.AssertionError:
Expected size: 2 but was: 1 in:
{0="foo"}

See gh-34768
pull/35405/head
Sam Brannen 7 months ago
parent
commit
b98c3257af
  1. 40
      spring-r2dbc/src/test/java/org/springframework/r2dbc/core/NamedParameterUtilsTests.java

40
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/NamedParameterUtilsTests.java

@ -21,6 +21,7 @@ import java.util.List; @@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map;
import io.r2dbc.spi.Parameters;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@ -384,6 +385,45 @@ class NamedParameterUtilsTests { @@ -384,6 +385,45 @@ class NamedParameterUtilsTests {
.containsEntry(2, List.of("baz"));
}
@Test // gh-34768
@Disabled("Disabled until gh-34768 is addressed")
void multipleEqualCollectionParameterReferencesForAnonymousMarkersBindsValueTwice() {
String sql = "SELECT * FROM fund_info WHERE fund_code IN (:fundCodes) OR fund_code IN (:fundCodes)";
MapBindParameterSource source = new MapBindParameterSource(Map.of("fundCodes", Parameters.in(List.of("foo"))));
PreparedOperation<String> operation = NamedParameterUtils.substituteNamedParameters(sql, ANONYMOUS_MARKERS, source);
assertThat(operation.toQuery())
.isEqualTo("SELECT * FROM fund_info WHERE fund_code IN (?) OR fund_code IN (?)");
Map<Integer, Object> bindings = new HashMap<>();
operation.bindTo(new BindTarget() {
@Override
public void bind(String identifier, Object value) {}
@Override
public void bind(int index, Object value) {
bindings.put(index, value);
}
@Override
public void bindNull(String identifier, Class<?> type) {
throw new UnsupportedOperationException();
}
@Override
public void bindNull(int index, Class<?> type) {
throw new UnsupportedOperationException();
}
});
assertThat(bindings)
.hasSize(2)
.containsEntry(0, "foo")
.containsEntry(1, "foo");
}
@Test
void multipleEqualParameterReferencesForAnonymousMarkersBindsValueTwice() {
String sql = "SELECT * FROM person where name = :id or lastname = :id";

Loading…
Cancel
Save