Skip to content

Check related ids in strict insertGraph() like upsertGraph() does (#538) - #539

Merged
lehni merged 1 commit into
mainfrom
fix/538
Oct 25, 2026
Merged

lehni merged 1 commit into
mainfrom
fix/538

Conversation

@lehni

@lehni lehni commented Oct 25, 2026

Copy link
Copy Markdown

Closes #538

Strict insertGraph() with added: 'relate' related ids that don't exist unchecked, since 4.3.0. It now looks them up before anything is written, with the same id-only query that upsertGraph() runs for related models since #372, and throws the same NotFoundError:

model (id=1000) does not exist. If you want to insert it with an id, set added: 'insert' for model1Relation1 in the relations option
  • loadCurrentGraph()'s final existence check is now markMissingModels(), which loadRelatedIds() also runs for strict inserts. Non-strict insertGraph() stays unchecked, as in 3.x.
  • The hint names added: 'insert' for insertGraph(), which has no relateOrInsert.
  • Behaviour change: strict inserts that wrote keys pointing to no row now throw, at the cost of one query per related model class.

@lehni
lehni enabled auto-merge (rebase) October 25, 2026 17:37
@lehni
lehni merged commit 565178d into main Oct 25, 2026
7 checks passed
@lehni
lehni deleted the fix/538 branch October 25, 2026 17:41
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.

Check related ids in strict insertGraph() like upsertGraph() does

1 participant