selene-db-gql 1.3.0

ISO/IEC 39075:2024 GQL parser, planner, optimizer, and executor for selene-db.
Documentation
//! Explicit TRIM formatter.

use std::fmt;

use crate::ast::{TrimSpec, ValueExpr};

pub(super) fn fmt_trim_expr(
    out: &mut String,
    spec: TrimSpec,
    character: Option<&ValueExpr>,
    source: &ValueExpr,
) -> fmt::Result {
    out.push_str("TRIM(");
    out.push_str(match spec {
        TrimSpec::Leading => "LEADING ",
        TrimSpec::Trailing => "TRAILING ",
        TrimSpec::Both => "BOTH ",
    });
    if let Some(character) = character {
        super::fmt_expr(out, character)?;
        out.push(' ');
    }
    out.push_str("FROM ");
    super::fmt_expr(out, source)?;
    out.push(')');
    Ok(())
}