pub enum SQLChunk<'a, V: SQLParam> {
Token(Token),
Ident(Cow<'a, str>),
Raw(Cow<'a, str>),
Number(usize),
Param(Param<'a, V>),
Table(TableSqlRef),
Column(ColumnSqlRef),
}Expand description
One piece of a SQL fragment.
The renderer puts spaces between chunks where SQL needs them, so chunks never carry their own surrounding whitespace.
Variants§
Token(Token)
A keyword, operator or punctuation: SELECT, =, (, …
Ident(Cow<'a, str>)
A quoted identifier (table, column or alias name): "name", or
`name` for MySQL.
Raw(Cow<'a, str>)
Raw SQL text, written as-is with no quoting: function names, expressions.
Number(usize)
An unsigned integer literal written into the SQL text, for clauses
such as LIMIT and OFFSET that are not parameterized.
Param(Param<'a, V>)
A placeholder and its bound value: ?, $1 or :name, depending on
the dialect and the placeholder.
Table(TableSqlRef)
A table, rendered as "schema"."table" or "table". Its column names
are used to expand an empty SELECT projection.
Column(ColumnSqlRef)
A column, rendered as "table"."column".
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.
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.
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 that borrows its value.
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 a value and placeholder.