pub struct WithClauseRef<'a> {
pub ctes: SmallVec<[CteRef<'a>; 4]>,
pub recursive: bool,
}Expand description
A builder for WITH clauses using zero-copy CTEs.
§Example
use prax_query::zero_copy::{CteRef, WithClauseRef};
use prax_query::sql::DatabaseType;
let with = WithClauseRef::new()
.cte(CteRef::new("active_users")
.columns(&["id", "name"])
.query("SELECT id, name FROM users WHERE active = true"))
.cte(CteRef::new("recent_orders")
.columns(&["user_id", "total"])
.query("SELECT user_id, SUM(amount) FROM orders GROUP BY user_id"));
let sql = with.build_select(&["*"], "active_users", DatabaseType::PostgreSQL);Fields§
§ctes: SmallVec<[CteRef<'a>; 4]>CTEs in this WITH clause.
recursive: boolWhether this is a recursive WITH.
Implementations§
Source§impl<'a> WithClauseRef<'a>
impl<'a> WithClauseRef<'a>
Sourcepub fn to_sql(&self, db_type: DatabaseType) -> String
pub fn to_sql(&self, db_type: DatabaseType) -> String
Build the WITH clause SQL.
Sourcepub fn build_select(
&self,
columns: &[&str],
from: &str,
db_type: DatabaseType,
) -> String
pub fn build_select( &self, columns: &[&str], from: &str, db_type: DatabaseType, ) -> String
Build a complete SELECT query with this WITH clause.
Trait Implementations§
Source§impl<'a> Clone for WithClauseRef<'a>
impl<'a> Clone for WithClauseRef<'a>
Source§fn clone(&self) -> WithClauseRef<'a>
fn clone(&self) -> WithClauseRef<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for WithClauseRef<'a>
impl<'a> Debug for WithClauseRef<'a>
Source§impl<'a> Default for WithClauseRef<'a>
impl<'a> Default for WithClauseRef<'a>
Source§fn default() -> WithClauseRef<'a>
fn default() -> WithClauseRef<'a>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<'a> Freeze for WithClauseRef<'a>
impl<'a> RefUnwindSafe for WithClauseRef<'a>
impl<'a> Send for WithClauseRef<'a>
impl<'a> Sync for WithClauseRef<'a>
impl<'a> Unpin for WithClauseRef<'a>
impl<'a> UnwindSafe for WithClauseRef<'a>
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