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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#[macro_export]
macro_rules! connection_method_wrapper {
    ($ty:path) => {
        impl ConnectionMethods for $ty {
            fn execute(&self, sql: &str) -> Result<()> {
                self.wrapped_connection_methods()?.execute(sql)
            }
            fn query(
                &self,
                table: &'static str,
                columns: &[Column],
                expr: Option<BoolExpr>,
                limit: Option<i32>,
                sort: Option<&[crate::query::Order]>,
            ) -> Result<RawQueryResult> {
                self.wrapped_connection_methods()?
                    .query(table, columns, expr, limit, sort)
            }
            fn insert_returning_pk(
                &self,
                table: &'static str,
                columns: &[Column],
                pkcol: &Column,
                values: &[SqlVal],
            ) -> Result<SqlVal> {
                self.wrapped_connection_methods()?
                    .insert_returning_pk(table, columns, pkcol, values)
            }
            fn insert_only(
                &self,
                table: &'static str,
                columns: &[Column],
                values: &[SqlVal],
            ) -> Result<()> {
                self.wrapped_connection_methods()?
                    .insert_only(table, columns, values)
            }
            fn insert_or_replace(
                &self,
                table: &'static str,
                columns: &[Column],
                pkcol: &Column,
                values: &[SqlVal],
            ) -> Result<()> {
                self.wrapped_connection_methods()?
                    .insert_or_replace(table, columns, pkcol, values)
            }
            fn update(
                &self,
                table: &'static str,
                pkcol: Column,
                pk: SqlVal,
                columns: &[Column],
                values: &[SqlVal],
            ) -> Result<()> {
                self.wrapped_connection_methods()?
                    .update(table, pkcol, pk, columns, values)
            }
            fn delete_where(&self, table: &'static str, expr: BoolExpr) -> Result<usize> {
                self.wrapped_connection_methods()?.delete_where(table, expr)
            }
            fn has_table(&self, table: &'static str) -> Result<bool> {
                self.wrapped_connection_methods()?.has_table(table)
            }
        }
    };
}