no-mistakes-postgres-sql 0.109.125

PostgreSQL SQL parsing, statement facts, and identifier extraction for no-mistakes
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use sqlparser::ast::{ObjectName, TableAlias, TableFactor, TableInheritance};

pub(super) fn lookup_table(factor: &TableFactor) -> Option<(&ObjectName, Option<&TableAlias>)> {
    match factor {
        TableFactor::Table {
            name,
            alias,
            args: None,
            sample: None,
            inheritance: None | Some(TableInheritance::IncludeDescendants),
            ..
        } if alias.as_ref().is_none_or(|alias| alias.columns.is_empty()) => {
            Some((name, alias.as_ref()))
        }
        _ => None,
    }
}