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

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>

Source

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

Creates a token chunk.

Source

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

Creates a quoted identifier from a static string.

Source

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

Creates raw SQL text from a static string.

Source

pub const fn table(table: TableRef) -> Self

Creates a table chunk.

Source

pub const fn column(column: ColumnRef) -> Self

Creates a column chunk.

Source

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

Creates a parameter chunk that borrows its value.

Source

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

Creates a quoted identifier.

Source

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

Creates raw SQL text.

Source

pub const fn number(value: usize) -> Self

Creates an unsigned integer literal chunk.

Source

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

Creates a parameter chunk with a value and placeholder.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Self

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 Param<'a, V>: Freeze,

§

impl<'a, V> RefUnwindSafe for SQLChunk<'a, V>
where Param<'a, V>: RefUnwindSafe,

§

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

§

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

§

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

§

impl<'a, V> UnsafeUnpin for SQLChunk<'a, V>
where Param<'a, V>: UnsafeUnpin,

§

impl<'a, V> UnwindSafe for SQLChunk<'a, V>
where Param<'a, V>: UnwindSafe,

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<List> ListIncludes<Nil, ()> for List

Source§

impl<Mk> MarkerAggValidFor<()> for Mk

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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