mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Unit of Work calculates unnecessary UPDATE queries for enum properties in cascaded collections #7059
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 @mbabker on GitHub (Oct 12, 2022).
Bug Report
Summary
While troubleshooting performance issues in one of our Symfony 6.1 applications, we found a request where a large number of UPDATE queries were being made which were generally unrelated to the actual request, screenshot is from New Relic:
Except for the
time_soldcolumn (unrelated to this bug report, it's something I still need to debug), all of the changes in the UPDATE statements are touching columns that use backed enums in their mapping.After debugging, I've found that this happens when persisting an entity that includes a "cascade persist" on a collection. When the unit of work calculates the change set with one of these entities loaded, it's computing the following change for one of these enum fields:
Current behavior
Unit of Work calculates incorrect changes, causing unnecessary UPDATE statements during a transaction
How to reproduce
https://github.com/mbabker/enum-uow-bug includes the minimal reproducer I was able to build to represent this issue.
Ensuring you have
sqliteavailable on your system, clone the repo and run the following commands:When the last command runs, it'll dump out the computed change set from the Unit of Work as well as the log records from the middleware:
Expected behavior
Changes aren't detected for unchanged enum properties, the above reproducer should have the following log output:
@W0rma commented on GitHub (Oct 13, 2022):
Could that be related to https://github.com/doctrine/orm/pull/10088 ?
@mbabker commented on GitHub (Oct 13, 2022):
Possibly related, but I patched my repro locally and it's still giving the extra UPDATE queries with it applied.
@mbabker commented on GitHub (Nov 23, 2022):
Looks to be fixed on current 2.13 dev build.