Skip to content

Run strict insertGraph() and upsertGraph() in a transaction (#429, #477) - #533

Merged
lehni merged 1 commit into
mainfrom
feature/429-strict-atomic
Oct 25, 2026
Merged

lehni merged 1 commit into
mainfrom
feature/429-strict-atomic

Conversation

@lehni

@lehni lehni commented Oct 25, 2026 •

Copy link
Copy Markdown

Strict insertGraph() and upsertGraph() (#429), including their *AndFetch variants, now always run in a transaction. A database error in a later write, e.g. a UniqueViolationError, then leaves none of the earlier writes behind.

  • The call starts its own transaction only if the query isn't already in one. A query that has a transaction passed to it, or whose model is bound to one, uses that transaction without a savepoint.
  • The transaction covers the whole call: the loads of upsertGraph(), the writes and the re-fetch of the *AndFetch variants. Hooks get it as context.transaction.
  • onError() handlers run after the rollback, on the query's own connection.
  • There's no opt-out. Hooks that run queries outside context.transaction wait for the transaction, and deadlock on SQLite with its single connection, so they need to use context.transaction. The docs say so.

Part of #477: non-strict graphs are unchanged, and making them atomic by default stays for the next major.

@lehni
lehni enabled auto-merge (squash) October 25, 2026 15:14
@lehni
lehni disabled auto-merge October 25, 2026 15:21
@lehni
lehni force-pushed the feature/429-strict-atomic branch from 2440f24 to b3a7cdf Compare October 25, 2026 15:21
@lehni lehni changed the title Run strict insertGraph() and upsertGraph() in a transaction (#429) Run strict insertGraph() and upsertGraph() in a transaction (#429, #477) Oct 25, 2026
@lehni
lehni enabled auto-merge (squash) October 25, 2026 15:21
@lehni
lehni merged commit 5bec15c into main Oct 25, 2026
7 checks passed
@lehni
lehni deleted the feature/429-strict-atomic branch October 25, 2026 15:28
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