Learn by example
7. Savepoints
Manual driver transactions expose named savepoints:
let mut transaction = pool.begin().await?;
transaction.execute("INSERT INTO users ...").await?;
transaction.savepoint("optional_commenter").await?;
transaction.execute("INSERT INTO users ...").await?;
transaction
.rollback_to_savepoint("optional_commenter")
.await?;
transaction.release_savepoint("optional_commenter").await?;
transaction.commit().await?;Names are validated before Rent emits SQL. Use savepoints for recoverable sub-steps; use the closure API when the whole operation should succeed or fail together.
The accompanying one-model schema is
crates/rent/examples/tutorial_06_savepoints/schema.rsl.
Run cargo run -p rent --example tutorial_06_savepoints. The same savepoint workflow runs under nextest.