Skip to content
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

Directus recreate an entry when updating a relationship #13042

Closed
shankiflang opened this issue Apr 28, 2022 · 8 comments · Fixed by #13151
Closed

Directus recreate an entry when updating a relationship #13042

shankiflang opened this issue Apr 28, 2022 · 8 comments · Fixed by #13151
Assignees
Labels

Comments

@shankiflang
Copy link

Describe the Bug

I have a little problem with the way Directus works.
To make it simple I'll explain:
I have a data model of recipes. In this one, I put an one to many to a data model that will act as a join. It will group the ingredients with their quantity and the unit (L, kg, ...) in the said recipe. (You can see the image)
When I add an ingredient and select it, everything is fine. The problem comes when I reopen a recipe with ingredients and I want to change the name of the ingredient or any other information. It will, instead of just changing the entry, recreate an ingredient. As I have put that the ingredients must be unique, I can't modify them in the recipes. I can only add them and once validated, it's over.
Do you know if I made a mistake with the relations or is it a problem in Directus?

To Reproduce

photo_2022-04-28_14-28-16

Errors Shown

No response

What version of Directus are you using?

9.9.0

What version of Node.js are you using?

16.14.2

What database are you using?

Postgre

What browser are you using?

Chrome

How are you deploying Directus?

Docker

@rijkvanzanten
Copy link
Member

Can you try updating to the latest version of Directus? I'm fairly sure this was fixed in #12840. We can reopen if it doesn't work in the latest version 👍🏻

@shankiflang
Copy link
Author

Can you try updating to the latest version of Directus? I'm fairly sure this was fixed in #12840. We can reopen if it doesn't work in the latest version 👍🏻

I updated Directus but still the error. Is there any particular manipulation to do other than changing the version of Directus?

@rijkvanzanten
Copy link
Member

Would you be able to share a database dump of a minimal reproduction? I have some trouble reproducing the setup based on the image and description alone (the exact relational configuration matters a lot here 🙂 )

@shankiflang
Copy link
Author

Would you be able to share a database dump of a minimal reproduction? I have some trouble reproducing the setup based on the image and description alone (the exact relational configuration matters a lot here 🙂 )

I can only retrieve the entire database. Where can I send it to you?

@shankiflang
Copy link
Author

@rijkvanzanten I made a directus test website. https://directustest.slatsh.com/ with defaut admin account. Is it okay for you to try ? (I looked and the error is still there)

@shankiflang
Copy link
Author

directustest.zip
And here is the sql

@br41nslug
Copy link
Member

This is happening because the o2m interface is not properly sending id's of relations on the junction table.

@br41nslug
Copy link
Member

br41nslug commented May 6, 2022

issue #12881 looks like the original marking this as duplicate

rijkvanzanten pushed a commit that referenced this issue May 9, 2022
* initial working fix for #13042 and #13058

* found an existing utility function that does exactly what was needed

* Apply O2M fields fix for similar interfaces
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants