Reset the input list of primary keys - callers may expect that!

This commit is contained in:
2023-05-10 17:59:25 -05:00
parent e9328c6653
commit 7a5124ae06

View File

@ -85,7 +85,8 @@ public class DeleteAction
String primaryKeyFieldName = table.getPrimaryKeyField(); String primaryKeyFieldName = table.getPrimaryKeyField();
QFieldMetaData primaryKeyField = table.getField(primaryKeyFieldName); QFieldMetaData primaryKeyField = table.getField(primaryKeyFieldName);
List<Serializable> primaryKeys = deleteInput.getPrimaryKeys(); List<Serializable> primaryKeys = deleteInput.getPrimaryKeys();
List<Serializable> originalPrimaryKeys = primaryKeys == null ? null : new ArrayList<>(primaryKeys);
if(CollectionUtils.nullSafeHasContents(primaryKeys) && deleteInput.getQueryFilter() != null) if(CollectionUtils.nullSafeHasContents(primaryKeys) && deleteInput.getQueryFilter() != null)
{ {
throw (new QException("A delete request may not contain both a list of primary keys and a query filter.")); throw (new QException("A delete request may not contain both a list of primary keys and a query filter."));
@ -173,6 +174,11 @@ public class DeleteAction
//////////////////////////////////// ////////////////////////////////////
DeleteOutput deleteOutput = deleteInterface.execute(deleteInput); DeleteOutput deleteOutput = deleteInterface.execute(deleteInput);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// reset the input's list of primary keys -- callers may use & expect that to be what they had passed in!! //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
deleteInput.setPrimaryKeys(originalPrimaryKeys);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// merge the backend's output with any validation errors we found (whose pkeys wouldn't have gotten into the backend delete) // // merge the backend's output with any validation errors we found (whose pkeys wouldn't have gotten into the backend delete) //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////