pub struct CTEView<'a, Table, Query> {
pub table: Table,
/* private fields */
}Expand description
A CTE (Common Table Expression) view that wraps an aliased table with its defining query.
This struct enables type-safe CTE usage by combining:
- An aliased table instance for typed field access
- The CTE definition (query) for the WITH clause
§Example
ⓘ
let active_users = builder
.select((user.id, user.name))
.from(user)
.as_cte("active_users");
// active_users.name works via Deref to the aliased table
builder
.with(&active_users)
.select(active_users.name)
.from(&active_users)Fields§
§table: TableThe aliased table for typed field access
Implementations§
Source§impl<'a, Table, Query> CTEView<'a, Table, Query>where
Query: ToSQL<'a, PostgresValue<'a>>,
impl<'a, Table, Query> CTEView<'a, Table, Query>where
Query: ToSQL<'a, PostgresValue<'a>>,
Trait Implementations§
Source§impl<'a, Table, Query> CTEDefinition<'a> for &CTEView<'a, Table, Query>where
Query: ToSQL<'a, PostgresValue<'a>>,
CTEDefinition for references.
impl<'a, Table, Query> CTEDefinition<'a> for &CTEView<'a, Table, Query>where
Query: ToSQL<'a, PostgresValue<'a>>,
CTEDefinition for references.
Source§fn cte_definition(&self) -> SQL<'a, PostgresValue<'a>>
fn cte_definition(&self) -> SQL<'a, PostgresValue<'a>>
Returns the SQL for the CTE definition (e.g., “cte_name AS (SELECT …)”)
Source§impl<'a, Table, Query> CTEDefinition<'a> for CTEView<'a, Table, Query>where
Query: ToSQL<'a, PostgresValue<'a>>,
CTEDefinition implementation for CTEView.
impl<'a, Table, Query> CTEDefinition<'a> for CTEView<'a, Table, Query>where
Query: ToSQL<'a, PostgresValue<'a>>,
CTEDefinition implementation for CTEView.
Source§fn cte_definition(&self) -> SQL<'a, PostgresValue<'a>>
fn cte_definition(&self) -> SQL<'a, PostgresValue<'a>>
Returns the SQL for the CTE definition (e.g., “cte_name AS (SELECT …)”)
Source§impl<'a, Table, Query> Deref for CTEView<'a, Table, Query>
Deref to the aliased table for field access.
impl<'a, Table, Query> Deref for CTEView<'a, Table, Query>
Deref to the aliased table for field access.
Source§impl<'a, Table, Query> ToSQL<'a, PostgresValue<'a>> for CTEView<'a, Table, Query>where
Query: ToSQL<'a, PostgresValue<'a>>,
ToSQL implementation renders just the CTE name for use in FROM clauses.
Unlike aliased tables (which render as “original” AS “alias”), CTEs
should just render as their name since they’re already defined in the WITH clause.
impl<'a, Table, Query> ToSQL<'a, PostgresValue<'a>> for CTEView<'a, Table, Query>where
Query: ToSQL<'a, PostgresValue<'a>>,
ToSQL implementation renders just the CTE name for use in FROM clauses. Unlike aliased tables (which render as “original” AS “alias”), CTEs should just render as their name since they’re already defined in the WITH clause.
Auto Trait Implementations§
impl<'a, Table, Query> Freeze for CTEView<'a, Table, Query>
impl<'a, Table, Query> !RefUnwindSafe for CTEView<'a, Table, Query>
impl<'a, Table, Query> Send for CTEView<'a, Table, Query>
impl<'a, Table, Query> Sync for CTEView<'a, Table, Query>
impl<'a, Table, Query> Unpin for CTEView<'a, Table, Query>
impl<'a, Table, Query> !UnwindSafe for CTEView<'a, Table, Query>
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