no-mistakes-postgres-sql 0.109.131

PostgreSQL SQL parsing, statement facts, and identifier extraction for no-mistakes
Documentation
use sqlparser::ast::{Expr, TrimWhereField};

pub(super) fn label(expr: &Expr) -> Option<&'static str> {
    Some(match expr {
        Expr::Extract { .. } => "extract",
        Expr::AtTimeZone { .. } => "timezone",
        Expr::Substring {
            shorthand: true, ..
        } => "substr",
        Expr::Substring { .. } => "substring",
        Expr::Trim {
            trim_where: Some(TrimWhereField::Leading),
            ..
        } => "ltrim",
        Expr::Trim {
            trim_where: Some(TrimWhereField::Trailing),
            ..
        } => "rtrim",
        Expr::Trim { .. } => "btrim",
        Expr::Overlay { .. } => "overlay",
        Expr::Position { .. } => "position",
        Expr::Ceil { .. } => "ceil",
        Expr::Floor { .. } => "floor",
        _ => return None,
    })
}