#[must_use = "Transaction builder does nothing unless you call `run` on it"]
pub struct TransactionBuilder<'a> { /* fields omitted */ }
Makes the transaction READ ONLY
conn.build_transaction()
.read_only()
.run::<_, diesel::result::Error, _>(|| {
let read_attempt = users.select(name).load::<String>(&conn);
assert!(read_attempt.is_ok());
let write_attempt = diesel::insert_into(users)
.values(name.eq("Ruby"))
.execute(&conn);
assert!(write_attempt.is_err());
Ok(())
})?;
Makes the transaction READ WRITE
This is the default, unless you've changed the
default_transaction_read_only
configuration parameter.
conn.build_transaction()
.read_write()
.run(|| {
let read_attempt = users.select(name).load::<String>(&conn);
assert!(read_attempt.is_ok());
let write_attempt = diesel::insert_into(users)
.values(name.eq("Ruby"))
.execute(&conn);
assert!(write_attempt.is_ok());
Ok(())
})
Makes the transaction DEFERRABLE
conn.build_transaction()
.deferrable()
.run(|| Ok(()))
Makes the transaction NOT DEFERRABLE
This is the default, unless you've changed the
default_transaction_deferrable
configuration parameter.
conn.build_transaction()
.not_deferrable()
.run(|| Ok(()))
Makes the transaction ISOLATION LEVEL READ COMMITTED
This is the default, unless you've changed the
default_transaction_isolation_level
configuration parameter.
conn.build_transaction()
.read_committed()
.run(|| Ok(()))
Makes the transaction ISOLATION LEVEL REPEATABLE READ
conn.build_transaction()
.repeatable_read()
.run(|| Ok(()))
Makes the transaction ISOLATION LEVEL SERIALIZABLE
conn.build_transaction()
.serializable()
.run(|| Ok(()))
Runs the given function inside of the transaction
with the parameters given to this builder.
Returns an error if the connection is already inside a transaction.
Walk over this QueryFragment
for all passes. Read more
Converts this QueryFragment
to its SQL representation. Read more
Serializes all bind parameters in this query. Read more
Is this query safe to store in the prepared statement cache? Read more
Performs copy-assignment from source
. Read more
Convert self
to an expression for Diesel's query builder. Read more
Convert &self
to an expression for Diesel's query builder. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static