Expand description
The isolation levels and SQLite modes as types: a table names one, and its dialect opens it
where it implements Opens for it.
A table that names a level carries it twice: as one of these types, which the bound on its
dialect checks when the service compiles, and as the Opening in its description, which
Dialect::begin turns into a statement.
§Examples
A dialect implements Opens for each level its begin opens:
use ruststream_sqlx_dialect::{
Dialect, Isolation, Opening, Opens, Statement, StatementError, TableSpec, level,
};
/// SQL Server, a database without a built-in dialect.
#[derive(Debug)]
pub struct Mssql;
impl Dialect for Mssql {
fn name(&self) -> &'static str {
"mssql"
}
fn begin(&self, opening: Opening) -> Result<Option<&'static str>, StatementError> {
match opening {
Opening::Default | Opening::Isolation(Isolation::ReadCommitted) => Ok(Some(
"SET TRANSACTION ISOLATION LEVEL READ COMMITTED; BEGIN TRANSACTION",
)),
Opening::Isolation(Isolation::RepeatableRead) => Ok(Some(
"SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; BEGIN TRANSACTION",
)),
other => Err(StatementError::UnsupportedOpening {
dialect: self.name(),
opening: other.name(),
}),
}
}
}
// A table at `read_committed` or `repeatable_read` mounts on `Mssql`.
impl Opens<level::ReadCommitted> for Mssql {}
impl Opens<level::RepeatableRead> for Mssql {}Structs§
- Deferred
Mode::Deferredas a type, for the boundOpenssets.- Exclusive
Mode::Exclusiveas a type, for the boundOpenssets.- Immediate
Mode::Immediateas a type, for the boundOpenssets.- Read
Committed Isolation::ReadCommittedas a type, for the boundOpenssets.- Read
Uncommitted Isolation::ReadUncommittedas a type, for the boundOpenssets.- Repeatable
Read Isolation::RepeatableReadas a type, for the boundOpenssets.- Serializable
Isolation::Serializableas a type, for the boundOpenssets.