tank_core/writer/
context.rs1#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
2pub enum Fragment {
3 SqlCommentOnColumn,
4 SqlCreateSchema,
5 SqlCreateTable,
6 SqlCreateTablePrimaryKey,
7 SqlCreateTableUnique,
8 SqlDeleteFrom,
9 SqlDeleteFromWhere,
10 SqlDropSchema,
11 SqlDropTable,
12 SqlInsertInto,
13 SqlInsertIntoOnConflict,
14 SqlInsertIntoValues,
15 SqlJoin,
16 #[default]
17 SqlSelect,
18 SqlSelectFrom,
19 SqlSelectOrderBy,
20 SqlSelectWhere,
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24pub struct Context {
25 pub fragment: Fragment,
26 pub qualify_columns: bool,
27}
28
29impl Context {
30 pub fn new(qualify_columns: bool) -> Self {
31 Self {
32 fragment: Default::default(),
33 qualify_columns,
34 }
35 }
36}
37
38impl Default for Context {
39 fn default() -> Self {
40 Context::new(true)
41 }
42}
43
44impl Context {
45 pub fn with_context(&self, fragment: Fragment) -> Self {
46 Self { fragment, ..*self }
47 }
48}