1mod assignments;
32pub use assignments::{Assignment, Assignments};
33
34mod association;
35pub use association::Association;
36
37mod condition;
38pub use condition::Condition;
39
40mod cte;
41pub use cte::Cte;
42
43mod cx;
44pub use cx::{DerivedRef, ExprContext, ExprTarget, IntoExprTarget, Resolve, ResolvedRef};
45
46mod delete;
47pub use delete::Delete;
48
49mod direction;
50pub use direction::Direction;
51
52mod entry;
53pub use entry::Entry;
54
55mod entry_mut;
56pub use entry_mut::EntryMut;
57
58mod entry_path;
59pub use entry_path::EntryPath;
60
61mod eval;
62
63mod expr;
64pub use expr::Expr;
65
66mod expr_and;
67pub use expr_and::ExprAnd;
68
69mod expr_any;
70pub use expr_any::ExprAny;
71
72mod expr_arg;
73pub use expr_arg::ExprArg;
74
75mod expr_binary_op;
76pub use expr_binary_op::ExprBinaryOp;
77
78mod expr_cast;
79pub use expr_cast::ExprCast;
80
81mod expr_error;
82pub use expr_error::ExprError;
83
84mod expr_exists;
85pub use expr_exists::ExprExists;
86
87mod expr_func;
88pub use expr_func::ExprFunc;
89
90mod expr_in_list;
91pub use expr_in_list::ExprInList;
92
93mod expr_in_subquery;
94pub use expr_in_subquery::ExprInSubquery;
95
96mod expr_is_null;
97pub use expr_is_null::ExprIsNull;
98
99mod expr_is_variant;
100pub use expr_is_variant::ExprIsVariant;
101
102mod expr_let;
103pub use expr_let::ExprLet;
104
105mod expr_list;
106pub use expr_list::ExprList;
107
108mod expr_map;
109pub use expr_map::ExprMap;
110
111mod expr_match;
112pub use expr_match::{ExprMatch, MatchArm};
113
114mod expr_not;
115pub use expr_not::ExprNot;
116
117mod expr_or;
118pub use expr_or::ExprOr;
119
120mod expr_project;
121pub use expr_project::ExprProject;
122
123mod expr_record;
124pub use expr_record::ExprRecord;
125
126mod expr_reference;
127pub use expr_reference::{ExprColumn, ExprReference};
128
129mod expr_set;
130pub use expr_set::ExprSet;
131
132mod expr_set_op;
133pub use expr_set_op::ExprSetOp;
134
135mod expr_stmt;
136pub use expr_stmt::ExprStmt;
137
138mod filter;
139pub use filter::Filter;
140
141mod hash_index;
142pub use hash_index::HashIndex;
143
144mod sorted_index;
145pub use sorted_index::SortedIndex;
146
147mod func_count;
148pub use func_count::FuncCount;
149
150mod func_last_insert_id;
151pub use func_last_insert_id::FuncLastInsertId;
152
153mod insert;
154pub use insert::Insert;
155
156mod insert_table;
157pub use insert_table::InsertTable;
158
159mod insert_target;
160pub use insert_target::InsertTarget;
161
162mod input;
163pub use input::{ConstInput, Input, TypedInput};
164
165mod join;
166pub use join::{Join, JoinOp};
167
168mod limit;
169pub use limit::Limit;
170
171#[cfg(feature = "assert-struct")]
172mod like;
173
174mod node;
175pub use node::Node;
176
177mod num;
178
179mod offset;
180pub use offset::Offset;
181
182mod op_binary;
183pub use op_binary::BinaryOp;
184
185mod order_by;
186pub use order_by::OrderBy;
187
188mod order_by_expr;
189pub use order_by_expr::OrderByExpr;
190
191mod op_set;
192pub use op_set::SetOp;
193
194mod path;
195pub use path::{Path, PathRoot};
196
197mod path_field_set;
198pub use path_field_set::PathFieldSet;
199
200mod projection;
201pub use projection::{Project, Projection};
202
203mod query;
204pub use query::{Lock, Query};
205
206mod returning;
207pub use returning::Returning;
208
209mod select;
210pub use select::Select;
211
212mod source;
213pub use source::{Source, SourceModel};
214
215mod source_table;
216pub use source_table::SourceTable;
217
218mod source_table_id;
219pub use source_table_id::SourceTableId;
220
221mod sparse_record;
222pub use sparse_record::SparseRecord;
223
224mod substitute;
225use substitute::Substitute;
226
227mod table_derived;
228pub use table_derived::TableDerived;
229
230mod table_ref;
231pub use table_ref::TableRef;
232
233mod table_factor;
234pub use table_factor::TableFactor;
235
236mod table_with_joins;
237pub use table_with_joins::TableWithJoins;
238
239mod ty;
240pub use ty::Type;
241
242mod ty_union;
243pub use ty_union::TypeUnion;
244
245#[cfg(feature = "jiff")]
246mod ty_jiff;
247
248mod update;
249pub use update::{Update, UpdateTarget};
250
251mod value;
252pub use value::Value;
253
254mod value_cmp;
255
256mod values;
257pub use values::Values;
258
259#[cfg(feature = "jiff")]
260mod value_jiff;
261
262mod value_record;
263pub use value_record::ValueRecord;
264
265pub mod visit_mut;
267pub use visit_mut::VisitMut;
268
269mod value_list;
270
271mod value_stream;
272pub use value_stream::ValueStream;
273
274pub mod visit;
276pub use visit::Visit;
277
278mod with;
279pub use with::With;
280
281use crate::schema::db::TableId;
282use std::fmt;
283
284#[derive(Clone, PartialEq)]
301pub enum Statement {
302 Delete(Delete),
304
305 Insert(Insert),
307
308 Query(Query),
310
311 Update(Update),
313}
314
315impl Statement {
316 pub fn name(&self) -> &str {
318 match self {
319 Statement::Query(_) => "query",
320 Statement::Insert(_) => "insert",
321 Statement::Update(_) => "update",
322 Statement::Delete(_) => "delete",
323 }
324 }
325
326 pub fn substitute(&mut self, input: impl Input) {
329 Substitute::new(input).visit_stmt_mut(self);
330 }
331
332 pub fn is_const(&self) -> bool {
335 match self {
336 Statement::Query(query) => {
337 if query.with.is_some() {
338 return false;
339 }
340
341 query.body.is_const()
342 }
343 _ => false,
344 }
345 }
346
347 pub fn as_update(&self) -> Option<&Update> {
353 match self {
354 Self::Update(update) => Some(update),
355 _ => None,
356 }
357 }
358
359 pub fn into_update(self) -> Option<Update> {
365 match self {
366 Self::Update(update) => Some(update),
367 _ => None,
368 }
369 }
370
371 pub fn into_update_unwrap(self) -> Update {
377 match self {
378 Self::Update(update) => update,
379 v => panic!("expected `Update`, found {v:#?}"),
380 }
381 }
382}
383
384impl Node for Statement {
385 fn visit<V: Visit>(&self, mut visit: V) {
386 visit.visit_stmt(self);
387 }
388
389 fn visit_mut<V: VisitMut>(&mut self, mut visit: V) {
390 visit.visit_stmt_mut(self);
391 }
392}
393
394impl fmt::Debug for Statement {
395 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
396 match self {
397 Self::Delete(v) => v.fmt(f),
398 Self::Insert(v) => v.fmt(f),
399 Self::Query(v) => v.fmt(f),
400 Self::Update(v) => v.fmt(f),
401 }
402 }
403}