8000 🐛 Bug Report: Multiple many to one relations in a database fail · Issue #6281 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

🐛 Bug Report: Multiple many to one relations in a database fail #6281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
hinnerkweiler opened this issue Sep 20, 2023 · 16 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working feature / relationships Fixes and upgrades for database relationships product / databases Fixes and upgrades for the Appwrite Database.

Comments

@hinnerkweiler
Copy link

👟 Reproduction steps

Create two Database collections and set a many to one or relation for a field from collection a to b. Now repeat the step for a second field. The second relation can not be created.

Tried this for many to one and many to many.

Originally raised and discussed this issue on Discord and was asked to file a bug report: https://discord.com/channels/564160730845151244/1152869638431068220

in depth sample: I have a collection Ports holding a list of available ports to travel to and from. I also have a collection Reservations where the user stores a travel plan. I need to reference Ports-Document two times in each Reservation, first for departure and than for destination. this seems to not be possible with the current relation management.

👍 Expected behavior

Allow multiple references from one collection to another.

👎 Actual Behavior

The Reference is only set up once, more fields fail at creation.

🎲 Appwrite version

Version 1.4.x

💻 Operating system

Linux

🧱 Your Environment

Tried in 1.4.2 and 1.4.3 plain install according docs docker run... on Ubuntu 22.04

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@hinnerkweiler hinnerkweiler added the bug Something isn't working label Sep 20, 2023
@btme0011
Copy link
Contributor
btme0011 commented Sep 20, 2023
        if ($attribute->getAttribute('type') === self::VAR_RELATIONSHIP
            && \strtolower($attribute->getAttribute('options')['twoWayKey']) === \strtolower($twoWayKey)
            && $attribute->getAttribute('options')['relatedCollection'] === $relatedCollection->getId()
        ) {
            throw new DuplicateException('Related attribute already exists');
        }

@btme0011
Copy link
Contributor
btme0011 commented Sep 20, 2023

In one way - As we can see from the code that if these three thing matched we throw DuplicateException. So if type is relationship , collecitonId is same and relatedColleciton id is also same it will throw this DuplicateException,

And in the case of Two way - twoWaykey contains the value of Attribute Key of related collection so if we put different Name of the attribute key of related collection we will not get the error.

@btme0011
Copy link
Contributor

@stnguyen90 can i work on this issue?

@stnguyen90 stnguyen90 added the product / databases Fixes and upgrades for the Appwrite Database. label Sep 20, 2023
@stnguyen90
Copy link
Contributor

@hinnerkweiler, thanks for raising this issue! 🙏🏼 Let me talk to the team about this.

@stnguyen90 stnguyen90 self-assigned this Sep 20, 2023
@stnguyen90
Copy link
Contributor

This might also apply to one to one relationships.

@moshOntong-IT
Copy link

any update on this issue?

@fogelito
Copy link
Contributor

yes @moshOntong-IT we are working on a fix for this issue 👍

@fogelito
Copy link
Contributor

@hinnerkweiler @moshOntong-IT
Until we finish working on this issue, as a work-around you can set twoWay = true and then you will have the option to set the twoWayKey with a unique name 👍

@stnguyen90 stnguyen90 moved this to In Progress in 1.4 release Oct 27, 2023
@stnguyen90 stnguyen90 added the feature / relationships Fixes and upgrades for database relationships label Oct 31, 2023
@rohankm
Copy link
rohankm commented Nov 1, 2023

@hinnerkweiler @moshOntong-IT Until we finish working on this issue, as a work-around you can set twoWay = true and then you will have the option to set the twoWayKey with a unique name 👍

How to set that?

@fogelito
Copy link
Contributor
fogelito commented Nov 2, 2023

@hinnerkweiler @moshOntong-IT Until we finish working on this issue, as a work-around you can set twoWay = true and then you will have the option to set the twoWayKey with a unique name 👍

How to set that?

Create a new Relation Two-way relationship, Since it is not editable, and you will see Attribute Key (related collection)
You can give it a unique name that will not trigger the error.

@rohankm
Copy link
rohankm commented Nov 2, 2023

@hinnerkweiler @moshOntong-IT Until we finish working on this issue, as a work-around you can set twoWay = true and then you will have the option to set the twoWayKey with a unique name 👍

How to set that?

Create a new Relation Two-way relationship, Since it is not editable, and you will see Attribute Key (related collection) You can give it a unique name that will not trigger the error.

Im still getting the error...

first relation Screenshot 2023-11-02 at 9 06 43 PM

2nd relation
Screenshot 2023-11-02 at 9 07 15 PM

@fogelito
Copy link
Contributor
fogelito commented Nov 5, 2023

Thanks @rohankm
Seems like on oneToOne / oneToMany it is working, but on manyToMany I can see some issues,
Will go back to the team with the insights 👍
Thanks again

@DanielRiveraHQ
Copy link
DanielRiveraHQ commented May 19, 2024

Hey @stnguyen90 ,

I tried to create the following relationships combinations in the same document and between another document, and the second one is not going through.

Let me know if you would like me to open a new issue with this one

CleanShot 2024-05-18 at 19 40 36@2x

CleanShot 2024-05-18 at 19 39 50@2x

@stnguyen90
Copy link
Contributor

@DanielRiveraHQ, you can try again when 1.5.6 is released in the next week or so.

@DanielRiveraHQ
Copy link

Great, thank you @stnguyen90

@DanielRiveraHQ
Copy link

@stnguyen90, just to report, it is working now; thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature / relationships Fixes and upgrades for database relationships product / databases Fixes and upgrades for the Appwrite Database.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

7 participants
0