Back

Issue with "onDelete": "setNull"

  • 0
  • Self Hosted
  • Databases
danstevenson_reyt
26 Apr, 2024, 11:47

I'm using Appwrite locally on version 1.4.13

I have two related collections: user_profile and climb . A user_profile can have many climbs, and a climb can have one user_profile.

When deleting a user_profile I want to do a setNull on the related climbs.

But when doing so, I get an Appwrite "Server Error"

My appwrite.json has this:

On the user_profile:

TypeScript
                {
                    "key": "climb",
                    "type": "relationship",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "relatedCollection": "65dcb2225a080e10109f",
                    "relationType": "oneToMany",
                    "twoWay": true,
                    "twoWayKey": "setter",
                    "onDelete": "setNull",
                    "side": "parent"
                }

On the climb:

TypeScript
                {
                    "key": "setter",
                    "type": "relationship",
                    "status": "available",
                    "error": "",
                    "required": false,
                    "array": false,
                    "relatedCollection": "65dcb0b8eb253f1b0df9",
                    "relationType": "oneToMany",
                    "twoWay": true,
                    "twoWayKey": "climb",
                    "onDelete": "setNull",
                    "side": "child"
                }

I can work around this by manually setting the climb.setter to null, but this seems to be functionality the "onDelete": "setNull" should do.

If I don't manually set the climb.setter to null, I can't delete the user_profile and get the "Server Error".

Please advise how I can update my JSON to get the required functionality, or confirm if this is a bug?

TL;DR
Developers want `onDelete: "setNull"` to work when deleting a `user_profile` to also nullify related `climb` entries, but it's causing a server error. Manually setting `climb.setter` to `null` resolves this. Confirm if it's a bug or how to update JSON for proper functionality.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more