|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2024 the original author or authors. |
|
|
|
|
* Copyright 2002-2025 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -211,6 +211,69 @@ abstract class AbstractDatabaseClientIntegrationTests {
@@ -211,6 +211,69 @@ abstract class AbstractDatabaseClientIntegrationTests {
|
|
|
|
|
.verifyComplete(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // gh-34768
|
|
|
|
|
void executeInsertWithReusedNamedParameter() { |
|
|
|
|
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory); |
|
|
|
|
|
|
|
|
|
Lego lego = new Lego(1, 42, "Star Wars", 42); |
|
|
|
|
|
|
|
|
|
databaseClient.sql(() -> "INSERT INTO legoset (id, version, name, manual) VALUES(:id, :number, :name, :number)") |
|
|
|
|
.bind("id", lego.id) |
|
|
|
|
.bind("name", lego.name) |
|
|
|
|
.bind("number", lego.version) |
|
|
|
|
.fetch().rowsUpdated() |
|
|
|
|
.as(StepVerifier::create) |
|
|
|
|
.expectNext(1L) |
|
|
|
|
.verifyComplete(); |
|
|
|
|
|
|
|
|
|
databaseClient.sql("SELECT * FROM legoset") |
|
|
|
|
.mapProperties(Lego.class) |
|
|
|
|
.first() |
|
|
|
|
.as(StepVerifier::create) |
|
|
|
|
.assertNext(actual -> assertThat(actual).isEqualTo(lego)) |
|
|
|
|
.verifyComplete(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // gh-34768
|
|
|
|
|
void executeSelectWithReusedNamedParameterList() { |
|
|
|
|
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory); |
|
|
|
|
|
|
|
|
|
String insertSql = "INSERT INTO legoset (id, version, name, manual) VALUES(:id, :version, :name, :manual)"; |
|
|
|
|
String selectSql = "SELECT * FROM legoset WHERE version IN (:numbers) OR manual IN (:numbers)"; |
|
|
|
|
Lego lego = new Lego(1, 42, "Star Wars", 99); |
|
|
|
|
|
|
|
|
|
databaseClient.sql(insertSql) |
|
|
|
|
.bind("id", lego.id) |
|
|
|
|
.bind("version", lego.version) |
|
|
|
|
.bind("name", lego.name) |
|
|
|
|
.bind("manual", lego.manual) |
|
|
|
|
.fetch().rowsUpdated() |
|
|
|
|
.as(StepVerifier::create) |
|
|
|
|
.expectNext(1L) |
|
|
|
|
.verifyComplete(); |
|
|
|
|
|
|
|
|
|
databaseClient.sql(selectSql) |
|
|
|
|
// match version
|
|
|
|
|
.bind("numbers", List.of(2, 3, lego.version, 4)) |
|
|
|
|
.mapProperties(Lego.class) |
|
|
|
|
.first() |
|
|
|
|
.as(StepVerifier::create) |
|
|
|
|
.assertNext(actual -> assertThat(actual).isEqualTo(lego)) |
|
|
|
|
.verifyComplete(); |
|
|
|
|
|
|
|
|
|
databaseClient.sql(selectSql) |
|
|
|
|
// match manual
|
|
|
|
|
.bind("numbers", List.of(2, 3, lego.manual, 4)) |
|
|
|
|
.mapProperties(Lego.class) |
|
|
|
|
.first() |
|
|
|
|
.as(StepVerifier::create) |
|
|
|
|
.assertNext(actual -> assertThat(actual).isEqualTo(lego)) |
|
|
|
|
.verifyComplete(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
record Lego(int id, Integer version, String name, Integer manual) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
record ParameterRecord(int id, String name, Integer manual) { |
|
|
|
|
} |
|
|
|
|
|