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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
//! `DELETE` builder states and clause methods.
//!
//! [`DeleteBuilder`] is the builder returned by `QueryBuilder::delete`.
//! `WHERE` and `RETURNING` may only read the table being deleted from; this
//! is checked at the method call.
use cratePostgresValue;
use PhantomData;
use ToSQL;
//------------------------------------------------------------------------------
// Type State Markers
//------------------------------------------------------------------------------
pub use ;
//------------------------------------------------------------------------------
// DeleteBuilder Definition
//------------------------------------------------------------------------------
/// A `PostgreSQL` `DELETE` being built: a [`QueryBuilder`](super::QueryBuilder)
/// in one of the `Delete*` states.
///
/// Add `WHERE` (required; `r#where(true)` deletes every row), then
/// optionally `RETURNING`.
///
/// # Examples
///
/// ```rust
/// # extern crate self as drizzle;
/// # mod _drizzle {
/// # pub mod core { pub use drizzle_core::*; }
/// # pub mod error { pub use drizzle_core::error::*; }
/// # pub mod types { pub use drizzle_types::*; }
/// # pub mod migrations { pub use drizzle_migrations::*; }
/// # pub use drizzle_types::Dialect;
/// # pub use drizzle_types as ddl;
/// # pub mod postgres {
/// # pub mod values { pub use drizzle_postgres::values::*; }
/// # pub mod traits { pub use drizzle_postgres::traits::*; }
/// # pub mod common { pub use drizzle_postgres::common::*; }
/// # pub mod attrs { pub use drizzle_postgres::attrs::*; }
/// # pub mod builder { pub use drizzle_postgres::builder::*; }
/// # pub mod helpers { pub use drizzle_postgres::helpers::*; }
/// # pub mod expr { pub use drizzle_postgres::expr::*; }
/// # pub mod types { pub use drizzle_postgres::types::*; }
/// # #[cfg(feature = "aws-data-api")]
/// # pub mod aws_data_api { pub use drizzle_postgres::aws_data_api::*; }
/// # pub struct Row;
/// # impl Row {
/// # pub fn get<'a, I, T>(&'a self, _: I) -> T { unimplemented!() }
/// # pub fn try_get<'a, I, T>(&'a self, _: I) -> Result<T, Box<dyn std::error::Error + Sync + Send>> { unimplemented!() }
/// # }
/// # pub mod prelude {
/// # pub use drizzle_macros::{PostgresTable, PostgresSchema, PostgresIndex};
/// # pub use drizzle_postgres::attrs::*;
/// # pub use drizzle_postgres::common::PostgresSchemaType;
/// # pub use drizzle_postgres::traits::{PostgresColumn, PostgresTable};
/// # pub use drizzle_postgres::values::{PostgresInsertValue, PostgresUpdateValue, PostgresValue};
/// # pub use drizzle_core::*;
/// # }
/// # }
/// # }
/// # pub use _drizzle::*;
/// # pub use const_format;
/// # fn main() {
/// # use drizzle::postgres::prelude::*;
/// # use drizzle::postgres::builder::QueryBuilder;
/// # #[PostgresTable(name = "users")]
/// # struct User {
/// # #[column(serial, primary)]
/// # id: i32,
/// # name: String,
/// # email: Option<String>,
/// # }
/// # #[PostgresTable(name = "posts")]
/// # struct Post {
/// # #[column(serial, primary)]
/// # id: i32,
/// # #[column(references = User::id)]
/// # author_id: i32,
/// # title: String,
/// # }
/// # #[derive(PostgresSchema)]
/// # struct Schema {
/// # user: User,
/// # post: Post,
/// # }
/// # let db = QueryBuilder::new::<Schema>();
/// # let Schema { user, post } = Schema::new();
/// use drizzle::core::expr::gt;
///
/// let query = db
/// .delete(user)
/// .r#where(gt(user.id, 10))
/// .returning(user.id);
/// assert_eq!(
/// query.to_sql().sql(),
/// r#"DELETE FROM "users" WHERE "users"."id" > $1 RETURNING "users"."id""#
/// );
/// # }
/// ```
pub type DeleteBuilder<'a, Schema, State, Table, Marker = , Row = > =
QueryBuilder;
type ReturningMarker<Table, Columns> = Scoped;
type ReturningRow<Table, Columns> =
Row;
type ReturningBuilder<'a, S, T, Columns> = ;
//------------------------------------------------------------------------------
// Initial State Implementation
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Post-WHERE Implementation
//------------------------------------------------------------------------------