#75 - Polishing.

Clarified code a little.

Added a warning to `AnonymousBindMarkers`:

 Anonymous bind markers are problematic because the have to appear in generated SQL in the same order they get generated.
 This might cause challenges in the future with complex generate statements.
 For example those containing subselects which limit the freedom of arranging bind markers.

Original pull request: #84.
This commit is contained in:
Jens Schauder
2019-04-17 16:22:21 +02:00
parent c9435c8797
commit 6227d96341
2 changed files with 14 additions and 2 deletions

View File

@@ -21,6 +21,12 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
* Anonymous, index-based bind marker using a static placeholder. Instances are bound by the ordinal position ordered by
* the appearance of the placeholder. This implementation creates indexed bind markers using an anonymous placeholder
* that correlates with an index.
* <p>
* Note: Anonymous bind markers are problematic because the have to appear in generated SQL in the same order they get generated.
*
* This might cause challenges in the future with complex generate statements.
* For example those containing subselects which limit the freedom of arranging bind markers.
* </p>
*
* @author Mark Paluch
*/

View File

@@ -209,13 +209,19 @@ public abstract class AbstractTransactionalDatabaseClientIntegrationTests extend
Flux<Object> transactionIds = databaseClient.inTransaction(db -> {
// We have to execute a sql statement first.
// Otherwise some databases (MySql) don't have a transaction id.
Mono<Integer> insert = db.execute().sql(getInsertIntoLegosetStatement()) //
.bind(0, 42055) //
.bind(1, "SCHAUFELRADBAGGER") //
.bindNull(2, Integer.class) //
.fetch().rowsUpdated();
Flux<Object> txId = db.execute().sql(getCurrentTransactionIdStatement()).map((r, md) -> r.get(0)).all();
Flux<Object> txId = db.execute() //
.sql(getCurrentTransactionIdStatement()) //
.map((row, md) -> row.get(0)) //
.all();
return insert.thenMany(txId.concatWith(txId));
});
@@ -223,7 +229,7 @@ public abstract class AbstractTransactionalDatabaseClientIntegrationTests extend
.consumeNextWith(actual -> {
assertThat(actual).hasSize(2);
assertThat(actual).containsExactly(actual.get(1), actual.get(0));
assertThat(actual.get(0)).isEqualTo(actual.get(1));
}) //
.verifyComplete();
}