Fully consume insert response.

R2dbcEntityTemplate.insert(…) now fully consumes the response from the INSERT call before continuing. Previously, we consumed only the first signal and continued then. A driver could emit a row and then an error signal and so the error signal would go unnoticed.

Closes #552.
This commit is contained in:
Mark Paluch
2021-03-09 16:08:17 +01:00
parent 34d8d10848
commit 91ee1365a8

View File

@@ -568,8 +568,8 @@ public class R2dbcEntityTemplate implements R2dbcEntityOperations, BeanFactoryAw
return this.databaseClient.sql(operation) //
.filter(statement -> statement.returnGeneratedValues())
.map(this.dataAccessStrategy.getConverter().populateIdIfNecessary(entity)) //
.first() //
.defaultIfEmpty(entity) //
.all() //
.last(entity)
.flatMap(saved -> maybeCallAfterSave(saved, outboundRow, tableName));
}