no-mistakes-postgres-sql 0.109.130

PostgreSQL SQL parsing, statement facts, and identifier extraction for no-mistakes
Documentation
use super::{SqlIsolation, SqlIsolationChanges};

/// Effect of a submitted SQL batch on a tracked executor's transaction.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SqlIsolationEffect {
    /// Set the isolation of an inherited open transaction.
    Existing(SqlIsolation),
    /// The batch leaves an explicit transaction open.
    Open(Option<SqlIsolation>),
    /// The batch finishes the transaction.
    Closed,
    /// The batch's transaction effects are uncertain.
    Unknown,
}

impl SqlIsolationChanges {
    pub fn after_call_effect(&self) -> Option<SqlIsolationEffect> {
        if self.unlocated {
            return Some(SqlIsolationEffect::Unknown);
        }
        let (_, last) = self.changes.last()?;
        if last.ends_call_transaction() {
            Some(SqlIsolationEffect::Closed)
        } else if last.has_explicit_transaction() {
            Some(SqlIsolationEffect::Open(self.effect))
        } else {
            self.effect.map(SqlIsolationEffect::Existing)
        }
    }
}