no-mistakes-postgres-sql 0.109.128

PostgreSQL SQL parsing, statement facts, and identifier extraction for no-mistakes
Documentation
use crate::statement_facts::{SqlIsolation, SqlIsolationChanges};
use sqlparser::tokenizer::{Location, Span};

#[derive(Debug, Clone, PartialEq, Eq)]
#[doc(hidden)]
pub struct InventoryLockFact {
    pub category: String,
    pub fingerprint: String,
    pub line: usize,
    pub column: usize,
    pub statement_start_line: usize,
    pub statement_start_column: usize,
    pub statement_end_line: usize,
    pub(super) in_stored_routine: bool,
}

impl InventoryLockFact {
    pub(super) fn new(category: &str, statement: &str, at: Location, span: Span) -> Self {
        Self {
            category: category.to_owned(),
            fingerprint: format!("{category}:{statement}"),
            line: at.line as usize,
            column: at.column as usize,
            statement_start_line: span.start.line as usize,
            statement_start_column: span.start.column as usize,
            statement_end_line: span.end.line as usize,
            in_stored_routine: false,
        }
    }

    pub fn isolation_at(
        &self,
        isolation: &SqlIsolationChanges,
        inherited: Option<SqlIsolation>,
    ) -> SqlIsolation {
        if self.in_stored_routine {
            SqlIsolation::Unknown
        } else {
            isolation.at(self.line, self.column, inherited)
        }
    }
}