mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3859: Overriding default identifier generation strategy has no effect on associations #4726
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jul 31, 2015).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user bostaf:
Hello everyone,
I have an entity with custom ID generator strategy. It works flawlessly.
In some circumstances I have to override this strategy with a "handmade" Id. It works when the main entity is being flushed without associations. But it doesn't work with associations. This example error is thrown:
{quote}
An exception occurred while executing 'INSERT INTO articles_tags (article_id, tag_id) VALUES (?, ?)' with params ["a004r0", 4]:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (sf-test1.articles_tags, CONSTRAINT FK_354053617294869C FOREIGN KEY (article_id) REFERENCES article (id) ON DELETE CASCADE)
{quote}
This is when foreign keys are configured. For testing I deleted the foreign keys definitions manually. The result was no error, and the associated entity was saved with the foreign key generated based on the default generation strategy (loosing the actual associations). I posted more details on how to reproduce on StackOverflow: http://stackoverflow.com/q/31594338/709626.
I first found the issue using "pure" Doctrine 2.5.0. Then, while trying to debug, I reproduced it in Symfony 2.7.2.
Actually I'm not sure whether it's a bug or I am doing something not correctly. Also this is my first report here so please let me know if I should provide any more details.
@doctrinebot commented on GitHub (Aug 9, 2015):
Comment created by bostaf:
The report is invalid. I was only setting
idGeneratorTypewhile I should also set
idGeneratorAdding the other line has fixed the problem.
@doctrinebot commented on GitHub (Aug 9, 2015):
Issue was closed with resolution "Invalid"