codeledge / ra-tools

React Admin Tools, namely the Prisma Data Adapter
66 stars 19 forks source link

Prisma error when updating a mongo record. #49

Closed codeninja closed 1 year ago

codeninja commented 1 year ago

image

I have this error on update which prevents me from updating the model. Prisma omits the ID on the update.

(the published issue is mine to fix)

I believe the same "filter out non-schema args" treatment that is applied to the create method would do the trick here.

image

mshd commented 1 year ago

Yes, the ID shouldn't be passed on. Have you checked our demo code? @ogroppo what about the "filter out non-schema args" for update?

ogroppo commented 1 year ago

Hi, in an edit resource the <TextInput source="id" /> should not be added, otherwise it will try to update :)

If you really want to have it on the UI, then you can pass to the updateHandler the options {skipFields: {id: true}}

In regard to filter out non-schema args that is for the filters I believe sending empty string instead of null (don't remember exactly under what conditions)

codeninja commented 1 year ago

@mshd Reviewing my code, I'm not displaying the ID on the form in any way but it's still being included in the post.

image image image image