[−][src]Struct diesel::pg::TransactionBuilder
Used to build a transaction, specifying additional details.
This struct is returned by .build_transaction
.
See the documentation for methods on this struct for usage examples.
See the PostgreSQL documentation for SET TRANSACTION
for details on the behavior of each option.
Methods
impl<'a> TransactionBuilder<'a>
[src]
pub fn read_only(self) -> Self
[src]
Makes the transaction READ ONLY
Example
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(()) })?;
pub fn read_write(self) -> Self
[src]
Makes the transaction READ WRITE
This is the default, unless you've changed the
default_transaction_read_only
configuration parameter.
Example
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(()) })
pub fn deferrable(self) -> Self
[src]
pub fn not_deferrable(self) -> Self
[src]
Makes the transaction NOT DEFERRABLE
This is the default, unless you've changed the
default_transaction_deferrable
configuration parameter.
Example
conn.build_transaction() .not_deferrable() .run(|| Ok(()))
pub fn read_committed(self) -> Self
[src]
Makes the transaction ISOLATION LEVEL READ COMMITTED
This is the default, unless you've changed the
default_transaction_isolation_level
configuration parameter.
Example
conn.build_transaction() .read_committed() .run(|| Ok(()))
pub fn repeatable_read(self) -> Self
[src]
Makes the transaction ISOLATION LEVEL REPEATABLE READ
Example
conn.build_transaction() .repeatable_read() .run(|| Ok(()))
pub fn serializable(self) -> Self
[src]
Makes the transaction ISOLATION LEVEL SERIALIZABLE
Example
conn.build_transaction() .serializable() .run(|| Ok(()))
pub fn run<T, E, F>(&self, f: F) -> Result<T, E> where
F: FnOnce() -> Result<T, E>,
E: From<Error>,
[src]
F: FnOnce() -> Result<T, E>,
E: From<Error>,
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.
Trait Implementations
impl<'a> Clone for TransactionBuilder<'a>
[src]
fn clone(&self) -> TransactionBuilder<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Copy for TransactionBuilder<'a>
[src]
impl<'a> QueryFragment<Pg> for TransactionBuilder<'a>
[src]
fn walk_ast(&self, out: AstPass<Pg>) -> QueryResult<()>
[src]
fn to_sql(&self, out: &mut DB::QueryBuilder) -> QueryResult<()>
[src]
fn collect_binds(
&self,
out: &mut DB::BindCollector,
metadata_lookup: &DB::MetadataLookup
) -> QueryResult<()>
[src]
&self,
out: &mut DB::BindCollector,
metadata_lookup: &DB::MetadataLookup
) -> QueryResult<()>
fn is_safe_to_cache_prepared(&self) -> QueryResult<bool>
[src]
Auto Trait Implementations
impl<'a> !RefUnwindSafe for TransactionBuilder<'a>
impl<'a> !Send for TransactionBuilder<'a>
impl<'a> !Sync for TransactionBuilder<'a>
impl<'a> Unpin for TransactionBuilder<'a>
impl<'a> !UnwindSafe for TransactionBuilder<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoSql for T
[src]
fn into_sql<T>(self) -> AsExprOf<Self, T> where
Self: AsExpression<T> + Sized,
[src]
Self: AsExpression<T> + Sized,
fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T> where
&'a Self: AsExpression<T>,
[src]
&'a Self: AsExpression<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,