toasty_core/stmt/
source_table.rs

1use crate::stmt::{ExprArg, Source, SourceTableId, TableFactor};
2
3use super::{TableRef, TableWithJoins};
4
5#[derive(Debug, Clone, PartialEq)]
6pub struct SourceTable {
7    /// All tables referenced in the statement
8    pub tables: Vec<TableRef>,
9
10    /// The main table with joins
11    pub from: Vec<TableWithJoins>,
12}
13
14impl SourceTable {
15    pub fn new(tables: Vec<TableRef>, from: TableWithJoins) -> Self {
16        Self {
17            tables,
18            from: vec![from],
19        }
20    }
21}
22
23impl From<ExprArg> for SourceTable {
24    fn from(value: ExprArg) -> Self {
25        SourceTable {
26            tables: vec![TableRef::Arg(value)],
27            from: vec![TableWithJoins {
28                relation: TableFactor::Table(SourceTableId(0)),
29                joins: vec![],
30            }],
31        }
32    }
33}
34
35impl From<SourceTable> for Source {
36    fn from(value: SourceTable) -> Self {
37        Source::Table(value)
38    }
39}