toasty_core/stmt/with.rs
1use super::Cte;
2
3/// A `WITH` clause containing one or more common table expressions (CTEs).
4///
5/// CTEs are temporary named result sets defined at the beginning of a query,
6/// referenced by [`TableRef::Cte`](super::TableRef) in the query body.
7///
8/// # Examples
9///
10/// ```ignore
11/// use toasty_core::stmt::{With, Cte, Query};
12///
13/// let with = With {
14/// ctes: vec![Cte { query: Query::unit() }],
15/// };
16/// assert_eq!(with.ctes.len(), 1);
17/// ```
18#[derive(Debug, Clone, PartialEq)]
19pub struct With {
20 /// The list of CTEs, referenced by index from [`TableRef::Cte`](super::TableRef).
21 pub ctes: Vec<Cte>,
22}
23
24impl From<Vec<Cte>> for With {
25 fn from(ctes: Vec<Cte>) -> Self {
26 Self { ctes }
27 }
28}