Skip to content

Commit b98c325

Browse files
committed
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
1 parent ea8ae09 commit b98c325

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

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

+40
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222

2323
import io.r2dbc.spi.Parameters;
24+
import org.junit.jupiter.api.Disabled;
2425
import org.junit.jupiter.api.Test;
2526
import org.junit.jupiter.params.ParameterizedTest;
2627
import org.junit.jupiter.params.provider.ValueSource;
@@ -384,6 +385,45 @@ public void bindNull(int index, Class<?> type) {
384385
.containsEntry(2, List.of("baz"));
385386
}
386387

388+
@Test // gh-34768
389+
@Disabled("Disabled until gh-34768 is addressed")
390+
void multipleEqualCollectionParameterReferencesForAnonymousMarkersBindsValueTwice() {
391+
String sql = "SELECT * FROM fund_info WHERE fund_code IN (:fundCodes) OR fund_code IN (:fundCodes)";
392+
393+
MapBindParameterSource source = new MapBindParameterSource(Map.of("fundCodes", Parameters.in(List.of("foo"))));
394+
PreparedOperation<String> operation = NamedParameterUtils.substituteNamedParameters(sql, ANONYMOUS_MARKERS, source);
395+
396+
assertThat(operation.toQuery())
397+
.isEqualTo("SELECT * FROM fund_info WHERE fund_code IN (?) OR fund_code IN (?)");
398+
399+
Map<Integer, Object> bindings = new HashMap<>();
400+
401+
operation.bindTo(new BindTarget() {
402+
@Override
403+
public void bind(String identifier, Object value) {}
404+
405+
@Override
406+
public void bind(int index, Object value) {
407+
bindings.put(index, value);
408+
}
409+
410+
@Override
411+
public void bindNull(String identifier, Class<?> type) {
412+
throw new UnsupportedOperationException();
413+
}
414+
415+
@Override
416+
public void bindNull(int index, Class<?> type) {
417+
throw new UnsupportedOperationException();
418+
}
419+
});
420+
421+
assertThat(bindings)
422+
.hasSize(2)
423+
.containsEntry(0, "foo")
424+
.containsEntry(1, "foo");
425+
}
426+
387427
@Test
388428
void multipleEqualParameterReferencesForAnonymousMarkersBindsValueTwice() {
389429
String sql = "SELECT * FROM person where name = :id or lastname = :id";

0 commit comments

Comments
 (0)