pub enum SQLChunk<'a, V: SQLParam> {
Token(Token),
Ident(Cow<'a, str>),
Raw(Cow<'a, str>),
Param(Param<'a, V>),
Table(&'static dyn SQLTableInfo),
Column(&'static dyn SQLColumnInfo),
Alias {
inner: Box<SQLChunk<'a, V>>,
alias: Cow<'a, str>,
},
}Expand description
A SQL chunk represents a part of an SQL statement.
This enum has 7 variants, each with a clear semantic purpose:
Token- SQL keywords and operators (SELECT, FROM, =, etc.)Ident- Quoted identifiers (“table_name”, “column_name”)Raw- Unquoted raw SQL text (function names, expressions)Param- Parameter placeholders with valuesTable- Table reference with metadata accessColumn- Column reference with metadata accessAlias- Alias wrapper (expr AS “name”)
Variants§
Token(Token)
SQL keywords and operators: SELECT, FROM, WHERE, =, AND, etc. Renders as: keyword with automatic spacing rules
Ident(Cow<'a, str>)
Quoted identifier for user-provided names Renders as: “name” (with quotes) Use for: table names, column names, alias names
Raw(Cow<'a, str>)
Raw SQL text (unquoted) for expressions, function names Renders as: text (no quotes, as-is) Use for: function names like COUNT, expressions, numeric literals
Param(Param<'a, V>)
Parameter with value and placeholder Renders as: ? or $1 or :name depending on placeholder style
Table(&'static dyn SQLTableInfo)
Table reference with full metadata access Renders as: “table_name” Provides: columns() for SELECT *, dependencies() for FK tracking
Column(&'static dyn SQLColumnInfo)
Column reference with full metadata access Renders as: “table”.“column” Provides: table(), is_primary_key(), foreign_key(), etc.
Alias
Alias wrapper: renders inner chunk followed by AS “alias” Renders as: {inner} AS “alias”
Implementations§
Source§impl<'a, V: SQLParam> SQLChunk<'a, V>
impl<'a, V: SQLParam> SQLChunk<'a, V>
Sourcepub const fn ident_static(name: &'static str) -> Self
pub const fn ident_static(name: &'static str) -> Self
Creates a quoted identifier from a static string - const
Sourcepub const fn raw_static(text: &'static str) -> Self
pub const fn raw_static(text: &'static str) -> Self
Creates raw SQL text from a static string - const
Sourcepub const fn table(table: &'static dyn SQLTableInfo) -> Self
pub const fn table(table: &'static dyn SQLTableInfo) -> Self
Creates a table chunk - const
Sourcepub const fn column(column: &'static dyn SQLColumnInfo) -> Self
pub const fn column(column: &'static dyn SQLColumnInfo) -> Self
Creates a column chunk - const
Sourcepub const fn param_borrowed(value: &'a V, placeholder: Placeholder) -> Self
pub const fn param_borrowed(value: &'a V, placeholder: Placeholder) -> Self
Creates a parameter chunk with borrowed value - const
Sourcepub fn ident(name: impl Into<Cow<'a, str>>) -> Self
pub fn ident(name: impl Into<Cow<'a, str>>) -> Self
Creates a quoted identifier from a runtime string
Sourcepub fn param(value: impl Into<Cow<'a, V>>, placeholder: Placeholder) -> Self
pub fn param(value: impl Into<Cow<'a, V>>, placeholder: Placeholder) -> Self
Creates a parameter chunk with owned value