Skip to main content

drizzle_sqlite/builder/
cte.rs

1//! Common table expressions (`WITH name AS (...)`) for `SQLite`.
2//!
3//! Make one with [`into_cte`](super::QueryBuilder::into_cte) and add it to a
4//! query with [`QueryBuilder::with`](super::QueryBuilder::with).
5
6use crate::values::SQLiteValue;
7
8/// A common table expression that can be passed to
9/// [`QueryBuilder::with`](super::QueryBuilder::with).
10///
11/// Implemented for every [`CTEView`], which
12/// [`into_cte`](super::QueryBuilder::into_cte) returns.
13pub trait CTEDefinition<'a>: drizzle_core::cte::CTEDefinition<'a, SQLiteValue<'a>> {}
14
15impl<'a, T> CTEDefinition<'a> for T where T: drizzle_core::cte::CTEDefinition<'a, SQLiteValue<'a>> {}
16
17/// A named SELECT used as a common table expression.
18///
19/// Created by [`into_cte`](super::QueryBuilder::into_cte). It derefs to an
20/// aliased copy of the source table, so `cte.column` gives typed column
21/// references that render as `"cte_name"."column"`.
22pub type CTEView<'a, Table, Query> = drizzle_core::cte::CTEView<'a, SQLiteValue<'a>, Table, Query>;