mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
After refresh my entity it is updated (doctrine do SQL UPDATE) #6879
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 @man-htsts on GitHub (Nov 24, 2021).
Bug Report
Summary
When i call refresh() on my entity, it is become unchanged (fresh state from DB). But then i call flush(), doctrine execute UPDATE statements, like my entity is still dirty.
Current behavior
It is because in UOW the entity is still in entityUpdates array.
And more to this, then in recomputeSingleEntityChangeSet() in the end the $changeSet is empty array, and the if clause
if ($changeSet)blocks doctrine to know that there is no real changes at the moment. And after it doctrine insert in DB old changes, that have been refreshed, but still stay in doctrine UOW $entityChangeSets cache.How to reproduce
Expected behavior
After refresh() it should not update my entity in DB.
It can be done, IMHO, if on refresh remove in from $entityUpdates and or from $changeSet. Or by patching recomputeSingleEntityChangeSet() to make it save if changeSet become empty.