Hi, I am not sure if it's a bug or I did not really see through the new collection relations.
I have e.g. a collection holding reservations for a boat ride from a to b. I also have a ports collection and would need to have a portsfrom field referencing a port in reservations. So far so easy. That works!
Now I add another field that references the destination portsto in the same way and that keeps failing.
Summary
The user is experiencing issues with creating multiple relations in a collection. They have a "reservations" collection and a "ports" collection. The first relation, "portsfrom," works fine, but when they try to add another relation, "portsto," it fails. The problem is that both relations have the same column/attribute key, causing a conflict. The solution is to use a two-way relationship and configure the column/attribute keys in the related collection to be different. The user is advised to create an issue on GitHub with this information.
Drake
Sep 18, 2023, 16:58
would you please provide more detail on the attributes including one/two way and the attribute keys?
ah very interesting...would you be able to create an issue and include this info in the issue?
The problem is a many to one relationship requires adding a column/attribute in the related collection. by default, the column/attribute key would be the source collection. however, the 2nd relationship would have the same column/attribute key causing the error
Drake
Sep 19, 2023, 19:36
if you use a two way relationship, you'll be able to configure the column/attribute key in the related collection, making it different, so they don't conflict
krennih
Rank 2: Process
Sep 19, 2023, 19:37
sure I will post the issue and try using a two way relation for the 2nd Port reference. Thanks for looking into this!
krennih
Rank 2: Process
Sep 20, 2023, 05:44
@Steven I tried the two-way-relation – unfortunately it does not work either. Also I raised the github issue
Drake
Sep 20, 2023, 17:23
Uh this is many to many now...
krennih
Rank 2: Process
Sep 20, 2023, 20:08
😵💫 It's just not my day today ...
Drake
Sep 20, 2023, 20:08
would you please check the docker logs in the appwrite-worker-databases for this one?
krennih
Rank 2: Process
Sep 20, 2023, 20:12
Ok, first it works with many to one.
krennih
Rank 2: Process
Sep 20, 2023, 20:24
Here's what happens when I try to create the second Attribute:
Like so?
krennih
Rank 2: Process
Sep 20, 2023, 20:29
And this when I add the 2nd field in a many-to-many relation:
Drake
Sep 20, 2023, 20:33
you mean only creating the 1st attribute works?
Drake
Sep 20, 2023, 20:35
or did you mean these logs are from when you tried creating the one-way many to one?
Drake
Sep 20, 2023, 20:36
ok we should treat this as a separate issue: Unable to create multiple many to many relationships between the same collections
krennih
Rank 2: Process
Sep 20, 2023, 20:45
🙈 My real life Problem is solved using your approach (Many-to-One in a two way Relationship wher I have PORTSFROM in Reservations related to RESERVATIONSTOHERE in the Ports Collection. The second field setting PORTSTO and RESERVATIONSTOHERE also works.
krennih
Rank 2: Process
Sep 20, 2023, 20:45
The first log is when I repeat the initial problem.
krennih
Rank 2: Process
Sep 20, 2023, 20:46
The second log is from the many-to-many issue. I can rais this on GitHub tomorrow separately.
btme0011
Sep 20, 2023, 21:21
Both attributes are two-way , many to one and their Attribute key of related collection is same ?
krennih
Rank 2: Process
Sep 21, 2023, 05:49
I deleted them and readded them for logging purposes