ORM-08: Add Database::transaction with savepoint nesting #8
Labels
No labels
area:core
area:database
area:migrations
area:model
area:relations
area:schema
area:tests
breaking-change
size:M
size:S
tracking
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
NoctisWolfshadow/tessera-orm#8
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Depends on: #6
Context
Model calls inside a transaction closure use the ambient connection, so nested model calls must work. rusqlite's
Transactionneeds&mut Connection, which would block that. Instead the transaction is driven with explicit SQL through&Connection, with a thread-local depth counter: the outermost call is a real transaction, nested calls are savepoints.Tasks
Database::transaction(|| -> Result<T>) -> Result<T>. Outermost:BEGIN IMMEDIATE/COMMIT/ROLLBACK. Nested:SAVEPOINT sp{n}/RELEASE/ROLLBACK TO+RELEASE.Droprolls back unless the closure completed.Database::transaction_depth() -> usize(#11 needs it).Example
SQL sent for the example above:
Acceptance criteria
Migrator::run()#11attach,detachandsyncfor many-to-many #22Not needed because of the Database Interface changes and reworks.