Skip to main content

no_mistakes_postgres_sql/function_calls/
fact.rs

1use super::SqlFunctionClause;
2use crate::statement_facts::{SqlIsolation, SqlIsolationChanges};
3
4/// One function expression, excluding column and alias identifiers.
5#[derive(Debug, Clone, PartialEq, Eq)]
6#[non_exhaustive]
7pub struct SqlFunctionCallFact {
8    pub name_parts: Vec<String>,
9    pub line: usize,
10    pub column: usize,
11    /// None for calls outside the supported clauses, including FROM and GROUP BY.
12    pub clause: Option<SqlFunctionClause>,
13    #[doc(hidden)]
14    pub in_cte: bool,
15    pub(crate) in_stored_routine: bool,
16}
17
18impl SqlFunctionCallFact {
19    /// Construct a call fact outside a CTE.
20    pub fn new(
21        name_parts: Vec<String>,
22        line: usize,
23        column: usize,
24        clause: Option<SqlFunctionClause>,
25    ) -> Self {
26        Self {
27            name_parts,
28            line,
29            column,
30            clause,
31            in_cte: false,
32            in_stored_routine: false,
33        }
34    }
35
36    pub fn isolation_at(
37        &self,
38        isolation: &SqlIsolationChanges,
39        line: usize,
40        column: usize,
41        inherited: Option<SqlIsolation>,
42    ) -> SqlIsolation {
43        if self.in_stored_routine {
44            SqlIsolation::Unknown
45        } else {
46            isolation.at(line, column, inherited)
47        }
48    }
49}