pub enum Casing {
Upper,
Lower,
Preserve,
}Expand description
How unquoted identifiers fold for identity in consumers such as planners.
The parser still interns the exact source text; this value describes later identity behaviour without losing render fidelity.
One tri-state models a single identity fold shared by every unquoted
identifier — table, column, and alias alike. That single-fold model is a
deliberate, parity-matching choice, not a gap: datafusion-sqlparser-rs, the
drop-in target, does not key case sensitivity by identifier kind either, so one
knob already meets parity and per-kind folding would be strictly more expressive
than parity requires. It also keeps the dialect model minimal.
Self::Lower approximates the MySQL/T-SQL column rule — “case-preserving
storage, case-insensitive comparison” — closely: fold lower for identity while
the interned text still renders exactly as written (folding is layered onto
the exact form, never baked into the parse).
§Known limitation: per-identifier-kind sensitivity
MySQL and T-SQL are case-insensitive for columns/aliases, but table and database
name sensitivity is a deployment setting (MySQL lower_case_table_names, the
T-SQL server/database collation). A case-insensitive column beside a
case-sensitive table cannot be expressed by one fold, and that deployment-config
knob is out of model; Self::Lower is the closest single fit and is what both
dialects use. Per-identifier-kind casing is a deliberate future extension, gated
on committing to a case-sensitive-table dialect (T-SQL): only then does the
table-vs-column split change parse/identity results, so until such a dialect
ships the added expressiveness would be unused surface (an M3 decision).
Variants§
Upper
Fold unquoted identifiers to upper case (Oracle/DB2 style).
Lower
Fold unquoted identifiers to lower case (PostgreSQL style).
Preserve
Preserve unquoted identifier case as written (MySQL/SQL Server style).
Implementations§
Source§impl Casing
impl Casing
Sourcepub fn fold_identifier<'a>(&self, identifier: &'a str) -> Cow<'a, str>
pub fn fold_identifier<'a>(&self, identifier: &'a str) -> Cow<'a, str>
Fold an unquoted identifier for dialect identity comparison.
M1 performs ASCII folding only. Non-ASCII bytes are preserved, matching the tokenizer’s permissive Unicode stance until a later precision pass introduces full Unicode identifier semantics.