Skip to content

Commit b827915

Browse files
committed
Polishing.
Remove unused imports. Use more explicit lambda parameter naming. Also, adopt tests to changed Spring Data Relational SQL generation. Original pull request: #690. See #689
1 parent 25323ca commit b827915

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

src/main/java/org/springframework/data/r2dbc/core/DefaultDatabaseClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ private <R> FetchSpec<R> exchangeInsert(BiFunction<Row, RowMetadata, R> mappingF
14861486

14871487
String sql = getRequiredSql(operation);
14881488
Function<Connection, Statement> insertFunction = wrapPreparedOperation(sql, operation)
1489-
.andThen(statement -> statement.returnGeneratedValues());
1489+
.andThen(Statement::returnGeneratedValues);
14901490
Function<Connection, Flux<Result>> resultFunction = toFunction(sql, StatementFilterFunctions.empty(),
14911491
insertFunction);
14921492

src/main/java/org/springframework/data/r2dbc/core/R2dbcEntityTemplate.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@ <T> Mono<T> doInsert(T entity, SqlIdentifier tableName) {
571571

572572
RelationalPersistentEntity<T> persistentEntity = getRequiredEntity(entity);
573573

574-
return maybeCallBeforeConvert(entity, tableName).flatMap(it -> {
574+
return maybeCallBeforeConvert(entity, tableName).flatMap(onBeforeConvert -> {
575575

576-
T initializedEntity = setVersionIfNecessary(persistentEntity, it);
576+
T initializedEntity = setVersionIfNecessary(persistentEntity, onBeforeConvert);
577577

578578
OutboundRow outboundRow = dataAccessStrategy.getOutboundRow(initializedEntity);
579579

@@ -676,25 +676,25 @@ private <T> Mono<T> doUpdate(T entity, SqlIdentifier tableName) {
676676

677677
RelationalPersistentEntity<T> persistentEntity = getRequiredEntity(entity);
678678

679-
return maybeCallBeforeConvert(entity, tableName).flatMap(it -> {
679+
return maybeCallBeforeConvert(entity, tableName).flatMap(onBeforeConvert -> {
680680

681681
T entityToUse;
682682
Criteria matchingVersionCriteria;
683683

684684
if (persistentEntity.hasVersionProperty()) {
685685

686-
matchingVersionCriteria = createMatchingVersionCriteria(it, persistentEntity);
687-
entityToUse = incrementVersion(persistentEntity, it);
686+
matchingVersionCriteria = createMatchingVersionCriteria(onBeforeConvert, persistentEntity);
687+
entityToUse = incrementVersion(persistentEntity, onBeforeConvert);
688688
} else {
689689

690-
entityToUse = it;
690+
entityToUse = onBeforeConvert;
691691
matchingVersionCriteria = null;
692692
}
693693

694694
OutboundRow outboundRow = dataAccessStrategy.getOutboundRow(entityToUse);
695695

696696
return maybeCallBeforeSave(entityToUse, outboundRow, tableName) //
697-
.flatMap(entityToSave -> {
697+
.flatMap(onBeforeSave -> {
698698

699699
SqlIdentifier idColumn = persistentEntity.getRequiredIdProperty().getColumnName();
700700
Parameter id = outboundRow.remove(idColumn);
@@ -704,7 +704,7 @@ private <T> Mono<T> doUpdate(T entity, SqlIdentifier tableName) {
704704
criteria = criteria.and(matchingVersionCriteria);
705705
}
706706

707-
return doUpdate(entityToSave, tableName, persistentEntity, criteria, outboundRow);
707+
return doUpdate(onBeforeSave, tableName, persistentEntity, criteria, outboundRow);
708708
});
709709
});
710710
}

src/test/java/org/springframework/data/r2dbc/core/DefaultDatabaseClientUnitTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void insertShouldAcceptSettableValue() {
256256
@Test // gh-390
257257
void insertShouldWorkWithoutValues() {
258258

259-
Statement statement = mockStatementFor("INSERT INTO id_only VALUES ()");
259+
Statement statement = mockStatementFor("INSERT INTO id_only VALUES (DEFAULT)");
260260
DatabaseClient databaseClient = databaseClientBuilder.build();
261261

262262
databaseClient.insert().into("id_only") //

src/test/java/org/springframework/data/r2dbc/core/R2dbcEntityTemplateUnitTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import io.r2dbc.spi.test.MockResult;
2323
import io.r2dbc.spi.test.MockRow;
2424
import io.r2dbc.spi.test.MockRowMetadata;
25-
import lombok.ToString;
2625
import lombok.Value;
2726
import lombok.With;
2827
import reactor.core.publisher.Mono;

0 commit comments

Comments
 (0)