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/// # Examples
30///
31/// ```ignore
32/// use toasty_core::stmt::{JoinOp, Expr};
33///
34/// let op = JoinOp::Left(Expr::TRUE);
35/// ```
36#[derive(Debug, Clone, PartialEq)]
37pub enum JoinOp {
38 /// An `INNER JOIN` with the given ON condition.
39 Inner(Expr),
40
41 /// A `LEFT JOIN` with the given ON condition.
42 Left(Expr),
43}