-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
DDC-1666: orphanRemoval does not work with oneToOne: Duplicate entry Error #2310
Comments
Comment created by @beberlei: This is a necessary restriction for the internals of Doctrine to always work correctly. |
Comment created by acasademont: +1 on this one. So what's the point of orphanRemoval in OneToOne if it can never be done? Maybe onetoones should not create a unique index but a normal one. If it is really a won't fix, then the docs should reflect that. |
Comment created by acasademont: BTW, as a workaround, i suggest converting this OneToOne case (where the orphanRemoval is in the inverse side) into a ManyToOne so a normal index will be created, not a unique one. Then the new row is inserted fine and the old one is deleted afterwards. |
Comment created by gutzuwissen: +1 |
Comment created by mnapoli: +1 same for me If the example of the docs isn't supposed to work (i.e. orphanRemoval with oneToOne isn't supported), then the docs should be updated. I can do a PR, but I need you to confirm it's really the case [~beberlei]. |
Comment created by @beberlei: Its indeed a good fix to disable the unique constraint if orphan removal isset. |
Comment created by @beberlei: Fixed and merged into 2.3 With the change Doctrine will not create unique indexes anymore on Orphan Removal OneToOne associations. You need to change the database schema for this change to take effect essentially. |
Issue was closed with resolution "Fixed" |
Am I doing something wrong or this is not resolved? I have doctrine/orm 2.16 and same error, same reason.. It looks like ClassMetadataInfo is setting 'unique' for join column therefore SchemaTool generates unique index on join column. |
Jira issue originally created by user gutzuwissen:
orphanRemoval does not work with oneToOne.
Im getting "duplicate entry" errors after replacing the oneToOne object.
Doctrine seems to insert the new data before removing the old one.
if i remove the unique constraint by hand in the database it works.
The text was updated successfully, but these errors were encountered: