|
21 | 21 | import java.util.Map;
|
22 | 22 |
|
23 | 23 | import io.r2dbc.spi.Parameters;
|
| 24 | +import org.junit.jupiter.api.Disabled; |
24 | 25 | import org.junit.jupiter.api.Test;
|
25 | 26 | import org.junit.jupiter.params.ParameterizedTest;
|
26 | 27 | import org.junit.jupiter.params.provider.ValueSource;
|
@@ -384,6 +385,45 @@ public void bindNull(int index, Class<?> type) {
|
384 | 385 | .containsEntry(2, List.of("baz"));
|
385 | 386 | }
|
386 | 387 |
|
| 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 | + |
387 | 427 | @Test
|
388 | 428 | void multipleEqualParameterReferencesForAnonymousMarkersBindsValueTwice() {
|
389 | 429 | String sql = "SELECT * FROM person where name = :id or lastname = :id";
|
|
0 commit comments