Skip to content

Fix false positive changes for generated columns by ignoring non-updatable/insertable columns#12385

Open
podoko wants to merge 3 commits intodoctrine:3.6.xfrom
podoko:fix-GH12017-ignore-changeset
Open

Fix false positive changes for generated columns by ignoring non-updatable/insertable columns#12385
podoko wants to merge 3 commits intodoctrine:3.6.xfrom
podoko:fix-GH12017-ignore-changeset

Conversation

@podoko
Copy link

@podoko podoko commented Mar 1, 2026

This is an alternative / complementary fix to #12384

After persisting or updating an entity having columns with the configuration generate: 'ALWAYS', the persister was updating the data on the entity but not notifying the UnitOfWork. This led the entity to be considered dirty in subsequent flushes, triggering lifecycle events. This was especially noticeable when the database field was mapped to a DateTime

This PR avoids the problem by making UnitOfWork::computeChangeSet and UnitOfWork::recomputeSingleEntityChangeSet skip fields that are not insertable/updatable when building the $actualData (for updates) and $changeSet (for insertions)


This approach can be used instead of #12384 since it fixes the bug as well, but it also prevents the entity from being considered dirty if a user tried to edit the value of a column that is not updatable. (eg: $entity->nonUpdatableField = 'new value';).

As showcased in GH12017ChangeSetTest.php, the changeSet passed in the lifecycle events will also not include these properties since they are not considered for update. The same goes for non-insertable fields. Depending on your sensibility, this could be considered a breaking change, that's why I didn't include it in my previous PR. Though, it is better at addressing the following points of the initial issue:

  • Fields marked with insertable: false should not appear in changesets for new entities during INSERT operations
  • Fields marked with updatable: false should not appear in changesets for existing entities during UPDATE operations

Fixes #12017

@podoko podoko changed the title Fix gh12017 ignore changeset Fix false positive changes for generated columns by ignoring non-updatable/insertable columns Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated columns with insertable/updatable=false cause false positive change detection

1 participant