Skip to content

Relate a BelongsToOneRelation model that upsertGraph() gets by its key alone - #473

Merged
lehni merged 1 commit into
nextfrom
fix/relate-without-id
Oct 15, 2026
Merged

lehni merged 1 commit into
nextfrom
fix/relate-without-id

Conversation

@lehni

@lehni lehni commented Oct 15, 2026

Copy link
Copy Markdown

upsertGraph() with relate relates a BelongsToOneRelation model without an id that gives the relation's key, e.g. { id: 1, owner: { code: 'c1' } } for a relation that joins pet.ownerCode to person.code, by writing the key to its owner. It then tried to patch that model through its id, and failed with "one of the identifier columns [id] is null or undefined" unless noUpdate was given, also in 3.x. It now writes only the key, without looking up the row, and throws a ValidationError of type InvalidGraph before anything is written when such a model gives other props that it would write, relations, or an #id that others refer to. Under noUpdate, a relation on such a model now throws too, where it was silently left out.

@lehni
lehni force-pushed the fix/relate-without-id branch from 98cb63c to 373886f Compare October 15, 2026 18:09
@lehni
lehni merged commit a0acb2a into next Oct 15, 2026
5 checks passed
@lehni
lehni deleted the fix/relate-without-id branch October 15, 2026 20:07
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.

1 participant