SQLChunk

Enum SQLChunk 

Source
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 values
  • Table - Table reference with metadata access
  • Column - Column reference with metadata access
  • Alias - 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”

Fields

§inner: Box<SQLChunk<'a, V>>
§alias: Cow<'a, str>

Implementations§

Source§

impl<'a, V: SQLParam> SQLChunk<'a, V>

Source

pub const fn token(t: Token) -> Self

Creates a token chunk - const

Source

pub const fn ident_static(name: &'static str) -> Self

Creates a quoted identifier from a static string - const

Source

pub const fn raw_static(text: &'static str) -> Self

Creates raw SQL text from a static string - const

Source

pub const fn table(table: &'static dyn SQLTableInfo) -> Self

Creates a table chunk - const

Source

pub const fn column(column: &'static dyn SQLColumnInfo) -> Self

Creates a column chunk - const

Source

pub const fn param_borrowed(value: &'a V, placeholder: Placeholder) -> Self

Creates a parameter chunk with borrowed value - const

Source

pub fn ident(name: impl Into<Cow<'a, str>>) -> Self

Creates a quoted identifier from a runtime string

Source

pub fn raw(text: impl Into<Cow<'a, str>>) -> Self

Creates raw SQL text from a runtime string

Source

pub fn param(value: impl Into<Cow<'a, V>>, placeholder: Placeholder) -> Self

Creates a parameter chunk with owned value

Source

pub fn alias(inner: SQLChunk<'a, V>, alias: impl Into<Cow<'a, str>>) -> Self

Creates an alias chunk wrapping any SQLChunk

Trait Implementations§

Source§

impl<'a, V: Clone + SQLParam> Clone for SQLChunk<'a, V>

Source§

fn clone(&self) -> SQLChunk<'a, V>

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<'a, V: SQLParam + Debug> Debug for SQLChunk<'a, V>

Source§

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

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

impl<'a, V: SQLParam> From<&'static dyn SQLColumnInfo> for SQLChunk<'a, V>

Source§

fn from(value: &'static dyn SQLColumnInfo) -> Self

Converts to this type from the input type.
Source§

impl<'a, V: SQLParam> From<&'static dyn SQLTableInfo> for SQLChunk<'a, V>

Source§

fn from(value: &'static dyn SQLTableInfo) -> Self

Converts to this type from the input type.
Source§

impl<V: SQLParam> From<OwnedSQLChunk<V>> for SQLChunk<'static, V>

Source§

fn from(value: OwnedSQLChunk<V>) -> Self

Converts to this type from the input type.
Source§

impl<'a, V: SQLParam> From<Param<'a, V>> for SQLChunk<'a, V>

Source§

fn from(value: Param<'a, V>) -> Self

Converts to this type from the input type.
Source§

impl<'a, V: SQLParam> From<SQLChunk<'a, V>> for OwnedSQLChunk<V>

Source§

fn from(value: SQLChunk<'a, V>) -> Self

Converts to this type from the input type.
Source§

impl<'a, V: SQLParam> From<Token> for SQLChunk<'a, V>

Source§

fn from(value: Token) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, V> Freeze for SQLChunk<'a, V>
where V: Freeze,

§

impl<'a, V> !RefUnwindSafe for SQLChunk<'a, V>

§

impl<'a, V> Send for SQLChunk<'a, V>
where V: Send + Sync,

§

impl<'a, V> Sync for SQLChunk<'a, V>
where V: Sync,

§

impl<'a, V> Unpin for SQLChunk<'a, V>
where V: Unpin,

§

impl<'a, V> !UnwindSafe for SQLChunk<'a, V>

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.