Closed copierrj closed 4 days ago
Thank you for reporting the issue. Do you have any minimal example somewhere?
I've created a small example project: https://github.com/copierrj/react-admin-test
A docker-compose for the backend (PostgreSQL + PostgREST) used by this project can be found here: https://github.com/copierrj/pagila/tree/postgrest
The problem is demonstrated in this form: https://github.com/copierrj/react-admin-test/blob/4161ffeb0c76dff5048156e5ae3f8dcf5b7175d6/src/CustomerEdit.tsx#L23-L37
Editing address details (stored in resource address
) without editing other customer information (stored in resource customer
) triggers the bug.
I have a few places I've run into this, one recently is many to many inputs trigger an empty patch on the edited resource
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: