no_mistakes_postgres_sql/statement_facts/isolation/
effect.rs1use super::{SqlIsolation, SqlIsolationChanges};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum SqlIsolationEffect {
6 Existing(SqlIsolation),
8 Open(Option<SqlIsolation>),
10 Closed,
12 Unknown,
14}
15
16impl SqlIsolationChanges {
17 pub fn after_call_effect(&self) -> Option<SqlIsolationEffect> {
18 if self.unlocated {
19 return Some(SqlIsolationEffect::Unknown);
20 }
21 let (_, last) = self.changes.last()?;
22 if last.ends_call_transaction() {
23 Some(SqlIsolationEffect::Closed)
24 } else if last.has_explicit_transaction() {
25 Some(SqlIsolationEffect::Open(self.effect))
26 } else {
27 self.effect.map(SqlIsolationEffect::Existing)
28 }
29 }
30}