pub struct SQL<'a, V: SQLParam> {
pub chunks: SmallVec<[SQLChunk<'a, V>; 8]>,
}Expand description
SQL fragment builder with flat chunk storage.
Uses SmallVec<[SQLChunk; 8]> for inline storage of typical SQL fragments
without heap allocation.
Fields§
§chunks: SmallVec<[SQLChunk<'a, V>; 8]>Implementations§
Source§impl<'a, V: SQLParam> SQL<'a, V>
impl<'a, V: SQLParam> SQL<'a, V>
Sourcepub fn placeholder(name: &'static str) -> Self
pub fn placeholder(name: &'static str) -> Self
Creates SQL with a named placeholder (no value, for prepared statements)
Sourcepub fn table(table: &'static dyn SQLTableInfo) -> Self
pub fn table(table: &'static dyn SQLTableInfo) -> Self
Creates SQL referencing a table
Sourcepub fn column(column: &'static dyn SQLColumnInfo) -> Self
pub fn column(column: &'static dyn SQLColumnInfo) -> Self
Creates SQL referencing a column
Sourcepub fn func(name: impl Into<Cow<'a, str>>, args: SQL<'a, V>) -> Self
pub fn func(name: impl Into<Cow<'a, str>>, args: SQL<'a, V>) -> Self
Creates SQL for a function call: NAME(args) Subqueries are automatically wrapped in parentheses: NAME((SELECT …))
Sourcepub fn append(self, other: impl Into<SQL<'a, V>>) -> Self
pub fn append(self, other: impl Into<SQL<'a, V>>) -> Self
Append another SQL fragment (flat extend)
Sourcepub fn with_capacity(self, additional: usize) -> Self
pub fn with_capacity(self, additional: usize) -> Self
Pre-allocates capacity for additional chunks
Sourcepub fn join<T>(sqls: T, separator: Token) -> SQL<'a, V>
pub fn join<T>(sqls: T, separator: Token) -> SQL<'a, V>
Joins multiple SQL fragments with a separator
Sourcepub fn is_subquery(&self) -> bool
pub fn is_subquery(&self) -> bool
Check if this SQL fragment is a subquery (starts with SELECT)
Sourcepub fn alias(self, name: impl Into<Cow<'a, str>>) -> SQL<'a, V>
pub fn alias(self, name: impl Into<Cow<'a, str>>) -> SQL<'a, V>
Creates an aliased version: self AS “name”
Sourcepub fn param_list<I>(values: I) -> Self
pub fn param_list<I>(values: I) -> Self
Creates a comma-separated list of parameters
Sourcepub fn assignments<I, T>(pairs: I) -> Self
pub fn assignments<I, T>(pairs: I) -> Self
Creates a comma-separated list of column assignments: “col” = ?
pub fn into_owned(&self) -> OwnedSQL<V>
Sourcepub fn write_chunk_to(
&self,
buf: &mut impl Write,
chunk: &SQLChunk<'a, V>,
index: usize,
)
pub fn write_chunk_to( &self, buf: &mut impl Write, chunk: &SQLChunk<'a, V>, index: usize, )
Write a single chunk with pattern detection
Sourcepub fn write_qualified_columns(
&self,
buf: &mut impl Write,
table: &dyn SQLTableInfo,
)
pub fn write_qualified_columns( &self, buf: &mut impl Write, table: &dyn SQLTableInfo, )
Write fully qualified columns
Trait Implementations§
Source§impl<'a, V: SQLParam, T> FromIterator<T> for SQL<'a, V>
impl<'a, V: SQLParam, T> FromIterator<T> for SQL<'a, V>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl<'a, V: SQLParam> IntoIterator for SQL<'a, V>
impl<'a, V: SQLParam> IntoIterator for SQL<'a, V>
Auto Trait Implementations§
impl<'a, V> Freeze for SQL<'a, V>where
V: Freeze,
impl<'a, V> !RefUnwindSafe for SQL<'a, V>
impl<'a, V> Send for SQL<'a, V>
impl<'a, V> Sync for SQL<'a, V>where
V: Sync,
impl<'a, V> Unpin for SQL<'a, V>where
V: Unpin,
impl<'a, V> !UnwindSafe for SQL<'a, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more