1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#[allow(dead_code)]
pub struct Join {
    table: String,
    join_type: JoinType,
    on: String,
}

#[allow(dead_code)]

impl Join {
    pub fn new(table: String, on: String, join_type: JoinType) -> Join {
        Join {
            table,
            on,
            join_type,
        }
    }

    pub fn build(&self) -> String {
        let join_type = match self.join_type {
            JoinType::Inner => "INNER",
            JoinType::Left => "LEFT",
            JoinType::Right => "RIGHT",
            JoinType::Full => "FULL",
            JoinType::LeftOuter => "LEFT OUTER",
            JoinType::RightOuter => "RIGHT OUTER",
        };

        let statement = format!("{} JOIN {} ON {} ", join_type, self.table, self.on);
        statement
    }
}

#[allow(dead_code)]
pub enum JoinType {
    Inner,
    Left,
    Right,
    RightOuter,
    LeftOuter,
    Full,
}