pub struct Sql { /* private fields */ }Expand description
A raw SQL query with parameterized values.
Implementations§
Source§impl Sql
impl Sql
Sourcepub fn with_db_type(self, db_type: DatabaseType) -> Self
pub fn with_db_type(self, db_type: DatabaseType) -> Self
Set the database type for parameter formatting.
Sourcepub fn bind(self, value: impl Into<FilterValue>) -> Self
pub fn bind(self, value: impl Into<FilterValue>) -> Self
Bind a parameter value.
Sourcepub fn bind_many(self, values: impl IntoIterator<Item = FilterValue>) -> Self
pub fn bind_many(self, values: impl IntoIterator<Item = FilterValue>) -> Self
Bind multiple parameter values at once.
Sourcepub fn push_if(self, condition: bool, sql: impl Into<String>) -> Self
pub fn push_if(self, condition: bool, sql: impl Into<String>) -> Self
Append a conditional clause.
Sourcepub fn bind_if(self, condition: bool, value: impl Into<FilterValue>) -> Self
pub fn bind_if(self, condition: bool, value: impl Into<FilterValue>) -> Self
Bind a parameter conditionally.
Sourcepub fn push_bind(
self,
sql: impl Into<String>,
value: impl Into<FilterValue>,
) -> Self
pub fn push_bind( self, sql: impl Into<String>, value: impl Into<FilterValue>, ) -> Self
Push SQL and bind a value together.
Sourcepub fn push_bind_if(
self,
condition: bool,
sql: impl Into<String>,
value: impl Into<FilterValue>,
) -> Self
pub fn push_bind_if( self, condition: bool, sql: impl Into<String>, value: impl Into<FilterValue>, ) -> Self
Push SQL and bind a value conditionally.
Sourcepub fn separated(self, separator: &str) -> SeparatedSql
pub fn separated(self, separator: &str) -> SeparatedSql
Add a separator between parts if there are previous parts.
Sourcepub fn build(self) -> (String, Vec<FilterValue>)
pub fn build(self) -> (String, Vec<FilterValue>)
Build the final SQL string and parameters.
Sourcepub fn params(&self) -> &[FilterValue]
pub fn params(&self) -> &[FilterValue]
Get the parameters (without consuming).
Sourcepub fn param_count(&self) -> usize
pub fn param_count(&self) -> usize
Get the number of bound parameters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sql
impl RefUnwindSafe for Sql
impl Send for Sql
impl Sync for Sql
impl Unpin for Sql
impl UnwindSafe for Sql
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
Mutably borrows from an owned value. Read more