-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Specs to show one-to-one relation integrity isn't respected #1426
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
Conversation
|
no, one-to-one relations aren't necessary unique. You can have a single object shared between multiple users. |
|
In that case it's a one-to-many? |
|
what do you mean? Case you provided is not valid for both one-to-many and one-to-one relations |
|
For a one-to-one relation, you shouldn't be able to have multiple access tokens for one user. If that were the case, it would be a many-to-one relation on the access token and one-to-many on the user. At the moment, it doesn't appear that there is any distinction between the columns created for these two types of relation. This is what the second spec is testing for. |
66d2bd7 to
048a8be
Compare
|
yes, sorry looks like I was wrong. What is your suggestion? Add unique constraint on one-to-one relations? |
|
Yes, I think it's a legitimated constraint to add 😄 I also think it could be done on top of this PR |
|
We can try to add |
|
I push the fix you proposed to see if the CI is happy with that. |
192e68d to
81a2636
Compare
|
@pleerock sorry for the delay, I've been busy. Setting unicity on the column works only when the table is joined with one column. That's why I add a unique index when the table is joined with multiple columns. Here is the created indexes on table What do you think of this solution so far? Some specs are missing, the same kind I added (checking trying to link the same object twice with a |
|
Can you please create this PR against |
81a2636 to
d3f2bd9
Compare
|
The branch has been rebased and I used a UNIQUE CONSTRAINT instead of an INDEX. The CI doesn't pass but it looks like it's already broken on |
|
Lets merge it and see how it will work. Thank you very much for contribution! |
|
@DFournier tests are failing currently on next and looks like because of this PR. Can you please take a look once? Why do you have |
|
Because otherwise the constraint is set on the column itself here. |
|
thats quite confusing logic and it should be set only in one place, otherwise it will be source of problems. |
|
I agree, this comes from the very first implementation. I create a fix now :) |

Hi!
Before investing more time on a bugfix, do you think those specs are correct?
For relational databases, I want to add a
UNIQUEconstraint on the foreign key column in order to enforceOneToOnerelation in both ways.