#250 - Throw IllegalArgumentException in StatementMapper if UPDATE contains no assignments.

We now properly throw an IllegalArgumentException. Previously, the update object was attempted to being mapped and this failed as the update object was null.
This commit is contained in:
Mark Paluch
2019-12-09 09:36:48 +01:00
parent 85acdbbd9a
commit 507340ea48
2 changed files with 25 additions and 4 deletions

View File

@@ -192,15 +192,15 @@ class DefaultStatementMapper implements StatementMapper {
BindMarkers bindMarkers = this.dialect.getBindMarkersFactory().create();
Table table = Table.create(updateSpec.getTable());
if (updateSpec.getUpdate() == null || updateSpec.getUpdate().getAssignments().isEmpty()) {
throw new IllegalArgumentException("UPDATE contains no assignments");
}
BoundAssignments boundAssignments = this.updateMapper.getMappedObject(bindMarkers,
updateSpec.getUpdate().getAssignments(), table, entity);
Bindings bindings;
if (boundAssignments.getAssignments().isEmpty()) {
throw new IllegalStateException("UPDATE contains no assignments");
}
bindings = boundAssignments.getBindings();
UpdateBuilder.UpdateWhere updateBuilder = StatementBuilder.update(table).set(boundAssignments.getAssignments());