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 Form | Description |
|---|---|
id | Unqualified column reference |
users.id | Table-qualified column reference |
myschema.users.id | Fully-qualified column reference |
§SQL:1999 Compliance
Per SQL:1999, identifier handling depends on whether each component was quoted:
| Input | Quoted | Canonical | Matches mycolumn? |
|---|---|---|---|
MyColumn | No | mycolumn | Yes |
"MyColumn" | Yes | MyColumn | No |
MYCOLUMN | No | mycolumn | Yes |
§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
impl ColumnIdentifier
Sourcepub fn simple(column: &str, quoted: bool) -> ColumnIdentifier
pub fn simple(column: &str, quoted: bool) -> ColumnIdentifier
Create a simple (unqualified) column identifier.
§Arguments
column- The column name as written by the userquoted- 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");Sourcepub fn qualified(
table: &str,
table_quoted: bool,
column: &str,
column_quoted: bool,
) -> ColumnIdentifier
pub fn qualified( table: &str, table_quoted: bool, column: &str, column_quoted: bool, ) -> ColumnIdentifier
Create a table-qualified column identifier.
§Arguments
table- The table name as written by the usertable_quoted- Whether the table was quoted in SQLcolumn- The column name as written by the usercolumn_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");Sourcepub fn fully_qualified(
schema: &str,
schema_quoted: bool,
table: &str,
table_quoted: bool,
column: &str,
column_quoted: bool,
) -> ColumnIdentifier
pub fn fully_qualified( schema: &str, schema_quoted: bool, table: &str, table_quoted: bool, column: &str, column_quoted: bool, ) -> ColumnIdentifier
Create a fully-qualified (schema.table.column) identifier.
§Arguments
schema- The schema name as written by the userschema_quoted- Whether the schema was quoted in SQLtable- The table name as written by the usertable_quoted- Whether the table was quoted in SQLcolumn- The column name as written by the usercolumn_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");Sourcepub fn unquoted(column: &str) -> ColumnIdentifier
pub fn unquoted(column: &str) -> ColumnIdentifier
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");Sourcepub fn quoted(column: &str) -> ColumnIdentifier
pub fn quoted(column: &str) -> ColumnIdentifier
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");Sourcepub fn table_column(table: &str, column: &str) -> ColumnIdentifier
pub fn table_column(table: &str, column: &str) -> ColumnIdentifier
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");Sourcepub fn from_canonical(canonical: String, quoted: bool) -> ColumnIdentifier
pub fn from_canonical(canonical: String, quoted: bool) -> ColumnIdentifier
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.
Sourcepub fn canonical(&self) -> &str
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”
Sourcepub fn display(&self) -> &str
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.
Sourcepub fn column_canonical(&self) -> &str
pub fn column_canonical(&self) -> &str
Get the column name in canonical form.
Sourcepub fn column_display(&self) -> &str
pub fn column_display(&self) -> &str
Get the column name in display form.
Sourcepub fn is_column_quoted(&self) -> bool
pub fn is_column_quoted(&self) -> bool
Check if the column was quoted.
Sourcepub fn table_canonical(&self) -> Option<&str>
pub fn table_canonical(&self) -> Option<&str>
Get the table name in canonical form (if qualified).
Sourcepub fn table_display(&self) -> Option<&str>
pub fn table_display(&self) -> Option<&str>
Get the table name in display form (if qualified).
Sourcepub fn is_table_quoted(&self) -> bool
pub fn is_table_quoted(&self) -> bool
Check if the table was quoted (if qualified).
Sourcepub fn schema_canonical(&self) -> Option<&str>
pub fn schema_canonical(&self) -> Option<&str>
Get the schema name in canonical form (if fully qualified).
Sourcepub fn schema_display(&self) -> Option<&str>
pub fn schema_display(&self) -> Option<&str>
Get the schema name in display form (if fully qualified).
Sourcepub fn is_schema_quoted(&self) -> bool
pub fn is_schema_quoted(&self) -> bool
Check if the schema was quoted (if fully qualified).
Sourcepub fn is_qualified(&self) -> bool
pub fn is_qualified(&self) -> bool
Check if this is a table-qualified column (has table but not schema).
Sourcepub fn is_fully_qualified(&self) -> bool
pub fn is_fully_qualified(&self) -> bool
Check if this is a fully-qualified column (has schema.table.column).
Sourcepub fn is_ambiguous(&self) -> bool
pub fn is_ambiguous(&self) -> bool
Check if this column reference is ambiguous (no table qualifier).
Sourcepub fn into_canonical(self) -> String
pub fn into_canonical(self) -> String
Get the canonical form as an owned String.
Sourcepub fn matches_column_name(&self, name: &str, case_sensitive: bool) -> bool
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.
Sourcepub fn resolve_against(&self, table: &TableIdentifier) -> ColumnIdentifier
pub fn resolve_against(&self, table: &TableIdentifier) -> ColumnIdentifier
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.
Sourcepub fn matches(&self, other: &ColumnIdentifier) -> bool
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
Sourcepub fn unqualify(&self) -> ColumnIdentifier
pub fn unqualify(&self) -> ColumnIdentifier
Create a column identifier by stripping qualifiers.
Returns a new unqualified column identifier with just the column name.
Sourcepub fn with_table(&self, table: &str, table_quoted: bool) -> ColumnIdentifier
pub fn with_table(&self, table: &str, table_quoted: bool) -> ColumnIdentifier
Create a column identifier with a different table qualifier.
Useful when remapping columns during query planning.
Trait Implementations§
Source§impl Clone for ColumnIdentifier
impl Clone for ColumnIdentifier
Source§fn clone(&self) -> ColumnIdentifier
fn clone(&self) -> ColumnIdentifier
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColumnIdentifier
impl Debug for ColumnIdentifier
Source§impl Display for ColumnIdentifier
impl Display for ColumnIdentifier
Source§impl From<&str> for ColumnIdentifier
impl From<&str> for ColumnIdentifier
Source§fn from(s: &str) -> ColumnIdentifier
fn from(s: &str) -> ColumnIdentifier
Convert from a string, assuming unquoted (case-insensitive).
Source§impl From<String> for ColumnIdentifier
impl From<String> for ColumnIdentifier
Source§fn from(s: String) -> ColumnIdentifier
fn from(s: String) -> ColumnIdentifier
Convert from a String, assuming unquoted (case-insensitive).
Source§impl Hash for ColumnIdentifier
impl Hash for ColumnIdentifier
Source§impl PartialEq for ColumnIdentifier
impl PartialEq for ColumnIdentifier
impl Eq for ColumnIdentifier
Auto Trait Implementations§
impl Freeze for ColumnIdentifier
impl RefUnwindSafe for ColumnIdentifier
impl Send for ColumnIdentifier
impl Sync for ColumnIdentifier
impl Unpin for ColumnIdentifier
impl UnwindSafe for ColumnIdentifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.