From f0232d2928613add8e59d40577f53b2089623955 Mon Sep 17 00:00:00 2001 From: Coleman Watts <coleman@civicrm.org> Date: Thu, 30 Jan 2020 16:41:40 -0500 Subject: [PATCH] Document change to APIv4 update/delete --- docs/api/v4/changes.md | 9 ++++++++- docs/api/v4/differences-with-v3.md | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/api/v4/changes.md b/docs/api/v4/changes.md index ef2ce626..ad9a2b7a 100644 --- a/docs/api/v4/changes.md +++ b/docs/api/v4/changes.md @@ -29,4 +29,11 @@ as those will always be `null`. ### 5.23 Get actions support selecting fields by * wildcard The `select` param now supports the `*` wildcard character for matching field names. -See [CiviCRM Core PR #16302](https://github.com/civicrm/civicrm-core/pull/16302) +See [CiviCRM Core PR #16302](https://github.com/civicrm/civicrm-core/pull/16302). + +### 5.23 Delete/Update do not throw error when 0 items found + +For consistency across all "batch-style" actions that update/delete records based on a query, +the `Delete` and `Update` actions now simply return an empty result if no matches are found to act upon. +Previously they would throw an exception, which was similar to APIv3 behavior but inconsistent with other +APIv4 batch actions and SQL in general. See [CiviCRM Core PR #16374](https://github.com/civicrm/civicrm-core/pull/16374). diff --git a/docs/api/v4/differences-with-v3.md b/docs/api/v4/differences-with-v3.md index 4699f1b5..ce0b85e5 100644 --- a/docs/api/v4/differences-with-v3.md +++ b/docs/api/v4/differences-with-v3.md @@ -93,6 +93,7 @@ them, it may help to have a concrete example expressed in both APIv3 and APIv4: * The `Create` action is now only used for creating *new* items (no more implicit update by passing an id to v3 `create`). * The `Save` action in v4 is most similar to v3's `create` - it accepts one or more records to create or update, infering the action based on the presence of `id` in each record. * `Update` and `Delete` can be performed on multiple items at once by specifying a `where` clause, vs a single item by id in v3. + Unlike v3, they will not complain if no matching items are found to update/delete and will return an empty result instead of an error. * `getsingle` is gone, use `$result->first()` or `index` `0`. * `getoptions` is no longer a standalone action, but part of `getFields`. -- GitLab