Back

[CLOSED] Relationship, can't delete related document even if on deleting: set null

  • 0
  • Databases
Bill.IHCha
15 Jul, 2023, 07:28

I'm not sure if this suppose to happen, but if you select set null on document deletion it's not the behaviour I expected. I would expect when deleting the related document the attribute of the current document will be set null, but it prevent the deletion of the related document, and when you delete the current document it basically does nothing. I'm talking about one way relationship btw. I have a user collection, and a stats collection. There is a relationship in user, which point to stats as one to one one way relation. I want to be able to freely delete the documents in stats collection and it will automatically set null on the user collection's relationship attribute.

TL;DR
The user is experiencing issues with deleting related documents in a one-way relationship. They expected that when deleting a related document, the attribute in the current document would be set to null, but instead, the deletion is prevented. The user has tried removing the child element before the parent and has not had success. They do not want to manually loop through all documents to remove the relationship. Currently, there is no solution provided in the support thread.
Bill.IHCha
15 Jul, 2023, 07:29

It doesn't matter that much, but it's just unclear

Bill.IHCha
15 Jul, 2023, 07:30

I don't want to loop through all documents in user collection and remove the relationship for stats, that will just not be ideal

Bill.IHCha
15 Jul, 2023, 09:10

version 1.3.7

Drake
15 Jul, 2023, 21:25

@joeyouss would you please troubleshoot this and try to reproduce the problem?

Bill.IHCha
16 Jul, 2023, 12:55

Any follow up?

Drake
16 Jul, 2023, 15:38

Since it's the weekend, people aren't around. You'll have to wait until maybe Monday

Bill.IHCha
16 Jul, 2023, 21:06

Alright, now it is

Bill.IHCha
18 Jul, 2023, 08:56

Any progress?

Drake
18 Jul, 2023, 17:31

@joeyouss would you please troubleshoot this and try to reproduce the problem?

Guille
18 Jul, 2023, 22:01

@Bill.IHCha Have you tried removing the parent document first? I'm working with relationship too and sometimes I get an error when I first remove the child element instead of the parent

Bill.IHCha
18 Jul, 2023, 22:02

I have to remove the parent to be able to delete the child, which I don't want. I want to be able to delete the child and parent attribute auto set null

joeyouss
19 Jul, 2023, 09:17

Thanks for the ping, missed the first one, looking into it

joeyouss
19 Jul, 2023, 09:36

@Bill.IHCha this is what I did:

  • Made 2 collections one and two
  • one has a relationship attribute with two (one to one and set NULL selected on deletion
  • made documents in both collections
  • deleted the document in two
joeyouss
19 Jul, 2023, 09:37

The result for me is: in one, two shows as n/a since it is deleted

I was able to delete it successfully though

joeyouss
19 Jul, 2023, 09:38

Can you confirm once the reproduction steps are okay? Because, it could be possible there are other attributes present in your collection and not in mine that are giving different answers

joeyouss
19 Jul, 2023, 09:39

Adding a related issue here https://github.com/appwrite/appwrite/issues/5558 (the error is different)

Bill.IHCha
19 Jul, 2023, 13:16

I'll try again once I get on. And I'll reply ping the message

joeyouss
20 Jul, 2023, 10:16

sure, I'll be waiting

Bill.IHCha
25 Jul, 2023, 08:22

Sorry for the late reply, but when I tested it in version 1.3.8 everything seems fine for now. I'll be reopening the issue once something occurs.

joeyouss
26 Jul, 2023, 21:07

thank you

joeyouss
26 Jul, 2023, 21:07

[CLOSED] Relationship, can't delete related document even if on deleting: set null

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