Skip to main content

SQLChunk

Enum SQLChunk 

Source
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

A SQL chunk represents a part of an SQL statement.

Each variant has 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 via TableSqlRef
  • Column - Column reference via ColumnSqlRef

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

§

Number(usize)

Unsigned integer SQL literal rendered directly without heap allocation.

Primarily used for clauses like LIMIT/OFFSET where numeric literals are embedded directly in SQL text rather than parameterized.

§

Param(Param<'a, V>)

Parameter with value and placeholder Renders as: ? or $1 or :name depending on placeholder style

§

Table(TableSqlRef)

Table reference with static name and column names. Renders as: “table_name” Column names used for SELECT * expansion.

§

Column(ColumnSqlRef)

Column reference with static table and column names. Renders as: “table_name"."column_name

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: TableRef) -> Self

Creates a table chunk - const

Source

pub const fn column(column: ColumnRef) -> 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 const fn number(value: usize) -> Self

Creates an unsigned integer SQL literal chunk.

Source

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

Creates a parameter chunk with owned value

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 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<V: SQLParam + Debug> Debug for SQLChunk<'_, V>

Source§

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

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

impl<V: SQLParam> From<ColumnRef> for SQLChunk<'_, V>

Source§

fn from(value: ColumnRef) -> 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<V: SQLParam> From<TableRef> for SQLChunk<'_, V>

Source§

fn from(value: TableRef) -> Self

Converts to this type from the input type.
Source§

impl<V: SQLParam> From<Token> for SQLChunk<'_, 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>
where V: RefUnwindSafe,

§

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> UnsafeUnpin for SQLChunk<'a, V>
where V: UnsafeUnpin,

§

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

Blanket Implementations§

Source§

impl<T> AliasExt for T

Source§

fn alias(self, name: &'static str) -> AliasedExpr<Self>

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<Mk> MarkerAggValidFor<()> for Mk

Source§

impl<Scope> ScopeSatisfies<Nil, ()> for Scope

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.
Source§

impl<T> TypeEq<T> for T