pub struct SQL<'a, V>where
V: SQLParam,{
pub chunks: SmallVec<[SQLChunk<'a, V>; 3]>,
}Expand description
A SQL statement or fragment with parameters.
This type is used to build SQL statements with proper parameter handling. It keeps track of both the SQL text and the parameters to be bound.
Fields§
§chunks: SmallVec<[SQLChunk<'a, V>; 3]>The chunks that make up this SQL statement or fragment.
Implementations§
Source§impl<'a, V> SQL<'a, V>where
V: SQLParam,
impl<'a, V> SQL<'a, V>where
V: SQLParam,
pub const fn new<'b>(chunks: [SQLChunk<'b, V>; 3]) -> SQL<'b, V>
pub fn into_owned(&self) -> OwnedSQL<V>
Sourcepub fn raw<T>(sql: T) -> SQL<'a, V>
pub fn raw<T>(sql: T) -> SQL<'a, V>
Creates a new SQL fragment from a raw string.
The string is treated as literal SQL text, not a parameter.
Sourcepub fn parameter(param: impl Into<Cow<'a, V>>) -> SQL<'a, V>
pub fn parameter(param: impl Into<Cow<'a, V>>) -> SQL<'a, V>
Creates a new SQL fragment representing a parameter.
A default positional placeholder (‘?’) is used, and the provided value is stored for later binding. Accepts both owned and borrowed values.
Sourcepub fn table(table: &'static dyn SQLTableInfo) -> SQL<'a, V>
pub fn table(table: &'static dyn SQLTableInfo) -> SQL<'a, V>
Creates a new SQL fragment representing a table.
pub fn column(column: &'static dyn SQLColumnInfo) -> SQL<'a, V>
Sourcepub fn placeholder(name: &'static str) -> SQL<'a, V>where
V: Default,
pub fn placeholder(name: &'static str) -> SQL<'a, V>where
V: Default,
Creates a named placeholder without a value - for use in query building. Similar to drizzle-orm’s sql.placeholder(‘name’). The value will be bound later during execution.
Sourcepub fn placeholder_with_style(
name: &'static str,
style: PlaceholderStyle,
) -> SQL<'a, V>where
V: Default,
pub fn placeholder_with_style(
name: &'static str,
style: PlaceholderStyle,
) -> SQL<'a, V>where
V: Default,
Creates a named placeholder with a specific style.
Sourcepub fn from_placeholder(placeholder: Placeholder) -> SQL<'a, V>where
V: Default,
pub fn from_placeholder(placeholder: Placeholder) -> SQL<'a, V>where
V: Default,
Creates SQL from an existing Placeholder struct.
Sourcepub fn append_raw(self, sql: impl AsRef<str>) -> SQL<'a, V>
pub fn append_raw(self, sql: impl AsRef<str>) -> SQL<'a, V>
Appends a raw string to this SQL fragment.
The string is treated as literal SQL text, not a parameter.
Sourcepub fn append(self, other: impl Into<SQL<'a, V>>) -> SQL<'a, V>
pub fn append(self, other: impl Into<SQL<'a, V>>) -> SQL<'a, V>
Appends another SQL fragment to this one.
Both the SQL text and parameters are merged.
Sourcepub fn with_capacity(self, additional: usize) -> SQL<'a, V>
pub fn with_capacity(self, additional: usize) -> SQL<'a, V>
Pre-allocates capacity for additional chunks.
Sourcepub fn join<T>(sqls: T, separator: &'static str) -> SQL<'a, V>
pub fn join<T>(sqls: T, separator: &'static str) -> SQL<'a, V>
Joins multiple SQL fragments with a separator.
The separator is inserted between each fragment, but not before the first or after the last.
Sourcepub fn sql(&self) -> String
pub fn sql(&self) -> String
Returns the SQL string represented by this SQL fragment, using placeholders for parameters.
pub fn bind( self, params: impl IntoIterator<Item = ParamBind<'a, V>>, ) -> SQL<'a, V>
Sourcepub fn params(&self) -> Vec<&V>
pub fn params(&self) -> Vec<&V>
Returns references to parameter values from this SQL fragment in the correct order.
Sourcepub fn alias(self, alias: impl Into<CompactString>) -> SQL<'a, V>
pub fn alias(self, alias: impl Into<CompactString>) -> SQL<'a, V>
Creates an aliased version of this SQL using the Alias chunk
Sourcepub fn parameters<I>(values: I) -> SQL<'a, V>
pub fn parameters<I>(values: I) -> SQL<'a, V>
Creates a comma-separated list of parameter placeholders with values: “?, ?, ?”
Sourcepub fn assignments<I, T>(pairs: I) -> SQL<'a, V>
pub fn assignments<I, T>(pairs: I) -> SQL<'a, V>
Creates a comma-separated list of column assignments: “col1 = ?, col2 = ?”
Trait Implementations§
Source§impl From<OwnedSQLiteValue> for SQL<'_, OwnedSQLiteValue>
impl From<OwnedSQLiteValue> for SQL<'_, OwnedSQLiteValue>
Source§fn from(value: OwnedSQLiteValue) -> Self
fn from(value: OwnedSQLiteValue) -> Self
Source§impl<'a> From<SQL<'a, SQLiteValue<'a>>> for SQLiteValue<'a>
impl<'a> From<SQL<'a, SQLiteValue<'a>>> for SQLiteValue<'a>
Source§fn from(_value: SQL<'a, SQLiteValue<'a>>) -> Self
fn from(_value: SQL<'a, SQLiteValue<'a>>) -> Self
Source§impl<'a> From<SQLiteValue<'a>> for SQL<'a, SQLiteValue<'a>>
impl<'a> From<SQLiteValue<'a>> for SQL<'a, SQLiteValue<'a>>
Source§fn from(value: SQLiteValue<'a>) -> Self
fn from(value: SQLiteValue<'a>) -> Self
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