lua_sql_builder/mysql/
join.rs

1#[allow(dead_code)]
2pub struct Join {
3    table: String,
4    join_type: JoinType,
5    on: String,
6}
7
8#[allow(dead_code)]
9
10impl Join {
11    pub fn new(table: String, on: String, join_type: JoinType) -> Join {
12        Join {
13            table,
14            on,
15            join_type,
16        }
17    }
18
19    pub fn build(&self) -> String {
20        let join_type = match self.join_type {
21            JoinType::Inner => "INNER",
22            JoinType::Left => "LEFT",
23            JoinType::Right => "RIGHT",
24            JoinType::Full => "FULL",
25            JoinType::LeftOuter => "LEFT OUTER",
26            JoinType::RightOuter => "RIGHT OUTER",
27        };
28
29        let statement = format!("{} JOIN {} ON {} ", join_type, self.table, self.on);
30        statement
31    }
32}
33
34#[allow(dead_code)]
35pub enum JoinType {
36    Inner,
37    Left,
38    Right,
39    RightOuter,
40    LeftOuter,
41    Full,
42}