sea_query/query/
mod.rs

1//! Query statements (select, insert, update & delete).
2//!
3//! # Usage
4//!
5//! - Query Select, see [`SelectStatement`]
6//! - Query Insert, see [`InsertStatement`]
7//! - Query Update, see [`UpdateStatement`]
8//! - Query Delete, see [`DeleteStatement`]
9
10mod case;
11mod condition;
12mod delete;
13mod insert;
14mod on_conflict;
15mod ordered;
16mod returning;
17mod select;
18mod traits;
19mod update;
20mod window;
21mod with;
22
23pub use case::*;
24pub use condition::*;
25pub use delete::*;
26pub use insert::*;
27pub use on_conflict::*;
28pub use ordered::*;
29pub use returning::*;
30pub use select::*;
31pub use traits::*;
32pub use update::*;
33pub use window::*;
34pub use with::*;
35
36/// Shorthand for constructing any table query
37#[derive(Debug, Clone)]
38pub struct Query;
39
40/// All available types of table query
41#[allow(clippy::large_enum_variant)]
42#[derive(Debug, Clone)]
43pub enum QueryStatement {
44    Select(SelectStatement),
45    Insert(InsertStatement),
46    Update(UpdateStatement),
47    Delete(DeleteStatement),
48}
49
50#[allow(clippy::large_enum_variant)]
51#[derive(Debug, Clone, PartialEq)]
52pub enum SubQueryStatement {
53    SelectStatement(SelectStatement),
54    InsertStatement(InsertStatement),
55    UpdateStatement(UpdateStatement),
56    DeleteStatement(DeleteStatement),
57    WithStatement(WithQuery),
58}
59
60impl Query {
61    /// Construct table [`SelectStatement`]
62    pub fn select() -> SelectStatement {
63        SelectStatement::new()
64    }
65
66    /// Construct table [`InsertStatement`]
67    pub fn insert() -> InsertStatement {
68        InsertStatement::new()
69    }
70
71    /// Construct table [`UpdateStatement`]
72    pub fn update() -> UpdateStatement {
73        UpdateStatement::new()
74    }
75
76    /// Construct table [`DeleteStatement`]
77    pub fn delete() -> DeleteStatement {
78        DeleteStatement::new()
79    }
80
81    /// Construct [`WithClause`]
82    pub fn with() -> WithClause {
83        WithClause::new()
84    }
85
86    /// Construct [`Returning`]
87    pub fn returning() -> Returning {
88        Returning::new()
89    }
90}