pub struct CteRef<'a> {
pub name: Cow<'a, str>,
pub columns: SmallVec<[Cow<'a, str>; 8]>,
pub query: Cow<'a, str>,
pub recursive: bool,
pub materialized: Option<bool>,
}Expand description
A zero-copy CTE definition that accepts column slices.
This is more efficient than Cte when working with static column lists.
§Example
use prax_query::zero_copy::CteRef;
use prax_query::sql::DatabaseType;
// Column names are borrowed from a static slice
let cte = CteRef::new("active_users")
.columns(&["id", "name", "email"])
.query("SELECT id, name, email FROM users WHERE active = true");
let sql = cte.to_sql(DatabaseType::PostgreSQL);Fields§
§name: Cow<'a, str>CTE name.
columns: SmallVec<[Cow<'a, str>; 8]>Column aliases (borrowed from slice).
query: Cow<'a, str>The defining query.
recursive: boolWhether this is recursive.
materialized: Option<bool>Materialization hint (PostgreSQL).
Implementations§
Source§impl<'a> CteRef<'a>
impl<'a> CteRef<'a>
Sourcepub fn columns_owned<I, S>(self, cols: I) -> Self
pub fn columns_owned<I, S>(self, cols: I) -> Self
Set column aliases (owned).
Sourcepub fn query_owned(self, q: String) -> Self
pub fn query_owned(self, q: String) -> Self
Set the defining query (owned).
Sourcepub fn materialized(self, mat: bool) -> Self
pub fn materialized(self, mat: bool) -> Self
Set materialization hint (PostgreSQL).
Sourcepub fn is_zero_copy(&self) -> bool
pub fn is_zero_copy(&self) -> bool
Check if this CTE uses only borrowed data.
Sourcepub fn to_sql(&self, db_type: DatabaseType) -> String
pub fn to_sql(&self, db_type: DatabaseType) -> String
Generate the CTE definition SQL.
Sourcepub fn to_owned_cte(&self) -> Cte
pub fn to_owned_cte(&self) -> Cte
Convert to owned Cte.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for CteRef<'a>
impl<'a> RefUnwindSafe for CteRef<'a>
impl<'a> Send for CteRef<'a>
impl<'a> Sync for CteRef<'a>
impl<'a> Unpin for CteRef<'a>
impl<'a> UnwindSafe for CteRef<'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