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

Remove unnecessary constraint in self-referencing many to many guide #4268

Conversation

greg-rychlewski
Copy link
Member

I saw this guide linked on Elixir Forum. When I read through it I noticed that there is an additional unique constraint that is not needed. If the constraint is on the pair then it doesn't matter what order the pair is presented in.

@josevalim
Copy link
Member

If the constraint is on the pair then it doesn't matter what order the pair is presented in.

This may not be true on some databases (MySQL). So perhaps we should keep it commented out with a note?

@greg-rychlewski
Copy link
Member Author

This may not be true on some databases (MySQL).

Ah sorry about that. I learned something new today. Just want to make sure I understand: is it because MySQL returns something like "duplicate entries for keys a,b" and so the exact constraint name can't be matched on?

@josevalim
Copy link
Member

I was thinking more from the performance side of things but I guess we are over-covered here. We already have indexes on individual columns, so I think we are good.

@greg-rychlewski greg-rychlewski merged commit 140c186 into elixir-ecto:master Aug 20, 2023
7 checks passed
@greg-rychlewski greg-rychlewski deleted the self_referencing_many_to_many branch August 20, 2023 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants