Why is Id AutoGenerated anew on UPDATE with Relation using Symfony Doctrine? #9081
Unanswered
dVVIIb
asked this question in
Support Questions
Replies: 1 comment
-
I'm moving this issue to discussions because we have stopped providing bugfix support for ORM 2.4 six years ago. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug Report
Summary
This has been rather difficult to diagnose especially as I was dealing with some complicated layered code. If I was sure, I would have filed a bug with Doctrine before now, but I wanted to first make sure I'm not making some glaring mistake or such, in implementation, so I posted a question on StackOverflow, first, but still have no answer.
I have painstakingly tried to reduce the code to a simplified working example. On my test database tables, there are additional columns that are not referred to in the demo code.
Current behavior
When this route ("/") is triggered, the record is updated and the old Id is displayed. But after the update, checking the database shows that the record now has a newly Auto-Generated Id, that comes after the last previous record in the table. Note that this is on UPDATE and not INSERT. The above is, as shown, OneToOne. I haven't yet checked whether the same issue occurs for OneToMany/ManyToOne Associations.
Of course, I realize this occurs because I'm using a new Associated child entity here, and can work around this by using an existing child object if any, but there may be a use case for a new child association (esp. if one wasn't assigned on persisting new parent Record), depending on application requirements, so a proper solution is needed anyway, I think.
How to reproduce
Please see above code samples and below:
These tables and above code are not completely compatible AS IS. Shown here in full, if necessary to help resolve the issue or if relevant in any way. You may need to exclude some columns, or add dummy columns to the entities in above code.
Expected behavior
(Record/row) Id should not be altered during update.
One urgent project of mine is held up due to this issue. Any assistance/clarification is appreciated.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions