Skip to main content

Casing

Enum Casing 

Source
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

Source

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.

Trait Implementations§

Source§

impl Clone for Casing

Source§

fn clone(&self) -> Casing

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Casing

Source§

impl Debug for Casing

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Casing

Source§

impl PartialEq for Casing

Source§

fn eq(&self, other: &Casing) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Casing

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.