Repository navigation
fix(core): update related entities with falsy primary keys in assign() - #8806
Merged
B4nan merged 2 commits intoNov 23, 2026
Merged
Conversation
With `updateByPrimaryKey`, `assign()` only matched a nested object to the existing related entity when its primary key was truthy. For a key of `0` or `''` the data was treated as a new entity instead, so the update of the existing to-one target or collection item was silently lost.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8806 +/- ##
=======================================
Coverage 99.64% 99.64%
=======================================
Files 294 294
Lines 32934 32934
Branches 9573 9573
=======================================
Hits 32817 32817
Misses 113 113
Partials 4 4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
B4nan
approved these changes
Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
updateByPrimaryKey(the default),assign()checksif (pk)before matching nested data to the existing related entity, both for to-one relations and for collection items. When that primary key is0or'', the check fails and the data goes throughem.create()instead, so the existing entity is not updated and the change is silently lost on flush.This switches both checks to
pk != null, the same fix #8757 made for the identity map lookup.