You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add keyless REST PUT/PATCH support for entities with auto-generated primary keys (#3150)
## Why make this change?
Closes#2663
One test change to help the pipeline pass relates to
#2992
## What is this change?
## Add keyless REST PUT/PATCH support for entities with auto-generated
primary keys
We now support keyless PUT/PATCH requests so long as the keys that are
missing are auto-generated by the entity in question. If the URL is
keyless, and the request body is keyless, then all of the keys needed
for the request must be auto-generated. If the request body contains
keys, then we allow the request only if the request body contains all
non auto-generated keys. So for example, if the entity has a composite
key, then it would be allowed to omit any auto-generated keys from that
composite key, but the non auto-generated keys must be included. This is
handled with new validation logic, which will now account for keyless
PUT/PATCH, simply validating that any non auto-generated keys are
included.
* In `OpenApiDocumentor`, keyless `PUT` and `PATCH` operations are now
documented for entities with auto-generated primary keys on the base
entity path. These use the `_NoAutoPK` request body schema and only
advertise `201 Created` responses. A missing `AddQueryParameters` helper
method was also added.
* Stored procedure entities are unaffected.
* Mutation engine is modified to detect the truly keyless operation in
case of Upsert/UpsertIncremental to then trigger the Insert workflow
instead otherwise the SQL statement will be incorrectly generated.
## How was this tested?
We modify existing tests to match the new behavior, and then add a test
for keyless PUT/PATCH.
## Sample Request(s)
```
PUT /api/Book
{
"title": "My New Book",
"publisher_id": 1234
}
PATCH /api/Book
{
"title": "Another New Book",
"publisher_id": 5678
}
```
---------
Co-authored-by: Aniruddh Munde <[email protected]>
privateconststringPUT_DESCRIPTION="Replace or create entity.";
46
+
privateconststringPUT_PATCH_KEYLESS_DESCRIPTION="Create entity (keyless). For entities with auto-generated primary keys, creates a new record without requiring the key in the URL.";
46
47
privateconststringPATCH_DESCRIPTION="Update or create entity.";
0 commit comments