Repository navigation
Write the foreign keys of has-many and has-one relates in upsertGraph() with noUpdate (#355) - #355
Merged
Merged
Conversation
lehni
force-pushed
the
fix/rc-noupdate-relate-main
branch
from
October 12, 2026 21:01
d1995d7 to
492ba2b
Compare
…() with noUpdate (#355)
lehni
force-pushed
the
fix/rc-noupdate-relate-main
branch
from
October 13, 2026 07:40
492ba2b to
b5d3867
Compare
Merged
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.
What
With
relateandnoUpdate,upsertGraph()patches the foreign keys of the models it relates through aHasManyRelationorHasOneRelation.GraphPatchActionadds the relation's related properties of nodes that it relates to the properties it writes, next to the BelongsToOneRelation keys it already collects withnoUpdate. The other properties of these models stay unwritten.Why
noUpdateonly skips the property updates, whilerelateexplicitly asks for the relate. The foreign key that the graph sets on the related model was never among the properties to write, so no query ran andupsertGraph()reported success with the model still related to its old owner, or to none. BelongsToOneRelation and ManyToManyRelation relates already write withnoUpdate. This has been the case since 1.5.0, whereupsertGraph()was rewritten.Tests
should only write the foreign key when hasManyRelation and hasOneRelation models are related with noUpdate: truerelates a model into a HasOneRelation and moves one from another owner into a HasManyRelation, and checks that only the foreign keys change. It fails without the change.The same fix for 4.0 is in #345. #334 and #336 also add a
## 3.9.1section to the changelog; whichever merges later combines them.