ColumnIdentifier

Struct ColumnIdentifier 

Source
pub struct ColumnIdentifier { /* private fields */ }
Expand description

A SQL column identifier with proper case handling per SQL:1999.

This type handles column references with optional table and schema qualifiers. Each component (schema, table, column) has independent quoted/unquoted semantics.

§Supported Forms

SQL FormDescription
idUnqualified column reference
users.idTable-qualified column reference
myschema.users.idFully-qualified column reference

§SQL:1999 Compliance

Per SQL:1999, identifier handling depends on whether each component was quoted:

InputQuotedCanonicalMatches mycolumn?
MyColumnNomycolumnYes
"MyColumn"YesMyColumnNo
MYCOLUMNNomycolumnYes

§Example

use vibesql_ast::ColumnIdentifier;

// Unquoted identifiers are case-insensitive
let c1 = ColumnIdentifier::simple("MyColumn", false);
let c2 = ColumnIdentifier::simple("mycolumn", false);
assert_eq!(c1, c2);

// Quoted identifiers are case-sensitive
let quoted = ColumnIdentifier::simple("MyColumn", true);
assert_ne!(c1, quoted);

// Table-qualified column
let qualified = ColumnIdentifier::qualified("users", false, "id", false);
assert_eq!(qualified.canonical(), "users.id");

Implementations§

Source§

impl ColumnIdentifier

Source

pub fn simple(column: &str, quoted: bool) -> Self

Create a simple (unqualified) column identifier.

§Arguments
  • column - The column name as written by the user
  • quoted - Whether the identifier was quoted (delimited) in SQL
§Example
use vibesql_ast::ColumnIdentifier;

let c = ColumnIdentifier::simple("MyColumn", false);
assert_eq!(c.canonical(), "mycolumn");
assert_eq!(c.display(), "MyColumn");
Source

pub fn qualified( table: &str, table_quoted: bool, column: &str, column_quoted: bool, ) -> Self

Create a table-qualified column identifier.

§Arguments
  • table - The table name as written by the user
  • table_quoted - Whether the table was quoted in SQL
  • column - The column name as written by the user
  • column_quoted - Whether the column was quoted in SQL
§Example
use vibesql_ast::ColumnIdentifier;

let c = ColumnIdentifier::qualified("Users", false, "ID", false);
assert_eq!(c.canonical(), "users.id");
assert_eq!(c.table_canonical(), Some("users"));
assert_eq!(c.column_canonical(), "id");
Source

pub fn fully_qualified( schema: &str, schema_quoted: bool, table: &str, table_quoted: bool, column: &str, column_quoted: bool, ) -> Self

Create a fully-qualified (schema.table.column) identifier.

§Arguments
  • schema - The schema name as written by the user
  • schema_quoted - Whether the schema was quoted in SQL
  • table - The table name as written by the user
  • table_quoted - Whether the table was quoted in SQL
  • column - The column name as written by the user
  • column_quoted - Whether the column was quoted in SQL
§Example
use vibesql_ast::ColumnIdentifier;

let c = ColumnIdentifier::fully_qualified(
    "myApp", true,   // quoted schema
    "users", false,  // unquoted table
    "ID", false      // unquoted column
);
assert_eq!(c.canonical(), "myApp.users.id");
Source

pub fn unquoted(column: &str) -> Self

Create an unquoted column identifier (convenience constructor).

This creates a simple, case-insensitive column reference.

§Example
use vibesql_ast::ColumnIdentifier;

let c = ColumnIdentifier::unquoted("MyColumn");
assert_eq!(c.canonical(), "mycolumn");
Source

pub fn quoted(column: &str) -> Self

Create a quoted column identifier (convenience constructor).

This creates a simple, case-sensitive column reference.

§Example
use vibesql_ast::ColumnIdentifier;

let c = ColumnIdentifier::quoted("MyColumn");
assert_eq!(c.canonical(), "MyColumn");
Source

pub fn table_column(table: &str, column: &str) -> Self

Create a table.column reference with unquoted identifiers.

§Example
use vibesql_ast::ColumnIdentifier;

let c = ColumnIdentifier::table_column("users", "id");
assert_eq!(c.canonical(), "users.id");
Source

pub fn from_canonical(canonical: String, quoted: bool) -> Self

Create an identifier from a canonical name (for internal use).

This is used when loading from persistence where we only have the canonical form. The display form is set to match canonical.

Source

pub fn canonical(&self) -> &str

Get the canonical form of the identifier.

This is used for HashMap keys and equality comparison. Format: “schema.table.column” or “table.column” or “column”

Source

pub fn display(&self) -> &str

Get the display form of the identifier.

This preserves the user’s original input and should be used in error messages and user-facing output.

Source

pub fn column_canonical(&self) -> &str

Get the column name in canonical form.

Source

pub fn column_display(&self) -> &str

Get the column name in display form.

Source

pub fn is_column_quoted(&self) -> bool

Check if the column was quoted.

Source

pub fn table_canonical(&self) -> Option<&str>

Get the table name in canonical form (if qualified).

Source

pub fn table_display(&self) -> Option<&str>

Get the table name in display form (if qualified).

Source

pub fn is_table_quoted(&self) -> bool

Check if the table was quoted (if qualified).

Source

pub fn schema_canonical(&self) -> Option<&str>

Get the schema name in canonical form (if fully qualified).

Source

pub fn schema_display(&self) -> Option<&str>

Get the schema name in display form (if fully qualified).

Source

pub fn is_schema_quoted(&self) -> bool

Check if the schema was quoted (if fully qualified).

Source

pub fn is_qualified(&self) -> bool

Check if this is a table-qualified column (has table but not schema).

Source

pub fn is_fully_qualified(&self) -> bool

Check if this is a fully-qualified column (has schema.table.column).

Source

pub fn is_ambiguous(&self) -> bool

Check if this column reference is ambiguous (no table qualifier).

Source

pub fn into_canonical(self) -> String

Get the canonical form as an owned String.

Source

pub fn matches_column_name(&self, name: &str, case_sensitive: bool) -> bool

Check if this column matches another by canonical column name only.

This ignores table and schema qualifiers, useful for finding columns by name across different tables.

Source

pub fn resolve_against(&self, table: &TableIdentifier) -> Self

Resolve an ambiguous column against a table.

If this column is unqualified, creates a new column identifier qualified with the given table. If already qualified, returns self.

Source

pub fn matches(&self, other: &ColumnIdentifier) -> bool

Check if this column reference matches another.

Matching rules:

  • An unqualified column matches if the column names match
  • A qualified column matches only if both table and column match
  • A fully-qualified column matches only if schema, table, and column match
Source

pub fn unqualify(&self) -> Self

Create a column identifier by stripping qualifiers.

Returns a new unqualified column identifier with just the column name.

Source

pub fn with_table(&self, table: &str, table_quoted: bool) -> Self

Create a column identifier with a different table qualifier.

Useful when remapping columns during query planning.

Trait Implementations§

Source§

impl Clone for ColumnIdentifier

Source§

fn clone(&self) -> ColumnIdentifier

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ColumnIdentifier

Source§

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

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

impl Display for ColumnIdentifier

Source§

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

Display uses the original user input form.

Source§

impl From<&str> for ColumnIdentifier

Source§

fn from(s: &str) -> Self

Convert from a string, assuming unquoted (case-insensitive).

Source§

impl From<String> for ColumnIdentifier

Source§

fn from(s: String) -> Self

Convert from a String, assuming unquoted (case-insensitive).

Source§

impl Hash for ColumnIdentifier

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Hash based on canonical form for consistent HashMap behavior.

1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ColumnIdentifier

Source§

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

Two column identifiers are equal if their canonical forms match.

1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ColumnIdentifier

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.