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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#![cfg(feature = "mysql")]
macro_rules! mysql_builder_constructors {
($runner:ty, [$($receiver:tt)*], $this:ident) => {
/// Starts a `SELECT` query.
///
/// `columns` is what to select: `()` for every column of the `FROM` table, a
/// column, a tuple of columns and expressions, or a `FromRow` type's
/// `::Select` marker. Follow it with `.from(..)`.
pub fn select<'db, 'q, T>(
$($receiver)*,
columns: T,
) -> DrizzleBuilder<
'db,
$runner,
Schema,
SelectBuilder<'q, Schema, SelectInitial, (), T::Marker>,
SelectInitial,
>
where
T: ToSQL<'q, MySQLValue<'q>> + drizzle_core::IntoSelectTarget,
{
DrizzleBuilder::new($this, QueryBuilder::new::<Schema>().select(columns))
}
/// Starts a `SELECT DISTINCT` query, which drops duplicate rows.
pub fn select_distinct<'db, 'q, T>(
$($receiver)*,
columns: T,
) -> DrizzleBuilder<
'db,
$runner,
Schema,
SelectBuilder<'q, Schema, SelectInitial, (), T::Marker>,
SelectInitial,
>
where
T: ToSQL<'q, MySQLValue<'q>> + drizzle_core::IntoSelectTarget,
{
DrizzleBuilder::new($this, QueryBuilder::new::<Schema>().select_distinct(columns))
}
/// Starts an `INSERT` into `table`.
///
/// Follow it with `.values(..)` and `Insert*` models, or with `.select(..)`
/// to insert a query's rows.
pub fn insert<'db, 'q, Table>(
$($receiver)*,
table: Table,
) -> DrizzleBuilder<
'db,
$runner,
Schema,
InsertBuilder<'q, Schema, InsertInitial, Table>,
InsertInitial,
>
where
Table: MySQLTable<'q>,
{
DrizzleBuilder::new($this, QueryBuilder::new::<Schema>().insert(table))
}
/// Starts an `UPDATE` of `table`.
///
/// Follow it with `.set(..)` and an `Update*` model, then `.r#where(..)`;
/// `.r#where(true)` updates every row.
pub fn update<'db, 'q, Table>(
$($receiver)*,
table: Table,
) -> DrizzleBuilder<
'db,
$runner,
Schema,
UpdateBuilder<'q, Schema, UpdateInitial, Table>,
UpdateInitial,
>
where
Table: MySQLTable<'q>,
{
DrizzleBuilder::new($this, QueryBuilder::new::<Schema>().update(table))
}
/// Starts a `DELETE` from `table`. It runs once `.r#where(..)` picks the
/// rows; `.r#where(true)` deletes every row.
pub fn delete<'db, 'q, Table>(
$($receiver)*,
table: Table,
) -> DrizzleBuilder<
'db,
$runner,
Schema,
DeleteBuilder<'q, Schema, DeleteInitial, Table>,
DeleteInitial,
>
where
Table: MySQLTable<'q>,
{
DrizzleBuilder::new($this, QueryBuilder::new::<Schema>().delete(table))
}
/// Starts a query with a common table expression: `WITH name AS (...)`.
pub fn with<'db, 'q, C>(
$($receiver)*,
cte: &C,
) -> DrizzleBuilder<
'db,
$runner,
Schema,
QueryBuilder<'q, Schema, builder::CTEInit>,
builder::CTEInit,
>
where
C: builder::CTEDefinition<'q>,
{
DrizzleBuilder::new($this, QueryBuilder::new::<Schema>().with(cte))
}
};
}
pub mod common;
#[cfg(any(feature = "mysql-sync", feature = "mysql-async"))]
pub(crate) mod driver_common;
#[cfg(any(feature = "mysql-sync", feature = "mysql-async"))]
mod introspect;
#[cfg(any(feature = "mysql-sync", feature = "mysql-async"))]
mod migration;
#[cfg(feature = "mysql-async")]
pub mod mysql_async;
#[cfg(feature = "mysql-sync")]
pub mod mysql_sync;