no-mistakes-postgres-sql 0.109.131

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
use super::Scope;
use crate::idents::ident_key;
use crate::statements::keyed_lookups::grouping::grouping_keys;
use sqlparser::ast::{Expr, GroupByExpr};

pub(super) fn collect(group_by: &GroupByExpr, scope: &mut Scope) {
    if let GroupByExpr::Expressions(expressions, _) = group_by {
        for expr in grouping_keys(expressions) {
            if matches!(expr, Expr::Identifier(ident) if scope.output_aliases.contains(&ident_key(ident)))
            {
                scope.group_names.insert(std::ptr::from_ref(expr));
            }
        }
    }
}