Repository navigation
Write the foreign keys of has-many and has-one relates in upsertGraph() with noUpdate (#53) - #345
Merged
Merged
Conversation
lehni
force-pushed
the
fix/rc-noupdate-relate
branch
from
October 12, 2026 21:02
c85c06a to
8b3c94d
Compare
…() with noUpdate (#53)
lehni
force-pushed
the
fix/rc-noupdate-relate
branch
from
October 12, 2026 21:18
8b3c94d to
37affb5
Compare
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 planned asrelateto the properties it writes, next to the BelongsToOneRelation and BelongsToManyRelation 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 thatGraphRelateor the parent's insert sets on the related model was never in the properties to write, so no query ran andupsertGraph()reported success with the model still related to its old owner. BelongsToOneRelation and ManyToManyRelation relates already write withnoUpdate. This has been the case since 1.5.0, whereupsertGraph()was rewritten. The same fix for 3.9.1 is in #355.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.Part of #53.