toasty_core/stmt/join.rs
1use super::{Expr, SourceTableId};
2
3/// A join clause within a [`TableWithJoins`](super::TableWithJoins).
4///
5/// References a table by [`SourceTableId`] and specifies the join type and
6/// condition via a [`JoinOp`].
7///
8/// # Examples
9///
10/// ```ignore
11/// use toasty_core::stmt::{Join, JoinOp, SourceTableId, Expr};
12///
13/// let join = Join {
14/// table: SourceTableId(1),
15/// constraint: JoinOp::Left(Expr::TRUE),
16/// };
17/// ```
18#[derive(Debug, Clone, PartialEq)]
19pub struct Join {
20 /// Index of the table to join, referencing [`SourceTable::tables`](super::SourceTable).
21 pub table: SourceTableId,
22
23 /// The join type and condition.
24 pub constraint: JoinOp,
25}
26
27/// The type of join and its ON condition.
28///
29/// Currently only left joins are supported.
30///
31/// # Examples
32///
33/// ```ignore
34/// use toasty_core::stmt::{JoinOp, Expr};
35///
36/// let op = JoinOp::Left(Expr::TRUE);
37/// ```
38#[derive(Debug, Clone, PartialEq)]
39pub enum JoinOp {
40 /// A `LEFT JOIN` with the given ON condition.
41 Left(Expr),
42}