ra-data-postgrest icon indicating copy to clipboard operation
ra-data-postgrest copied to clipboard

Update fails when nothing is changed

Open copierrj opened this issue 8 months ago • 2 comments

When manipulating multiple related resources in a single form (using ReferenceManyInput, ReferenceOneInput, etc.) the update function of the data provider gets called for every resource. When no fields of a particular resource are changed update gets called with the same value for 'data' and 'previousData'.

Because ra-data-postgrest only updates changed fields, a PATCH request with an empty object ({}) is send to PostgREST resulting in an error:

{
     "code":"PGRST116",
     "details":"The result contains 0 rows",
     "hint":null,
     "message":"JSON object requested, multiple (or no) rows returned"
}

copierrj avatar Jun 19 '24 09:06 copierrj