1use crate::{Values, expr::*, query::*};
4use std::fmt::Debug;
5
6use crate::extension::postgres::PgBinOper;
7
8use crate::extension::sqlite::SqliteBinOper;
9
10mod iden;
12
13pub use iden::*;
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum UnOper {
18 Not,
19}
20
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum BinOper {
26 And,
27 Or,
28 Like,
29 NotLike,
30 Is,
31 IsNot,
32 In,
33 NotIn,
34 Between,
35 NotBetween,
36 Equal,
37 NotEqual,
38 SmallerThan,
39 GreaterThan,
40 SmallerThanOrEqual,
41 GreaterThanOrEqual,
42 Add,
43 Sub,
44 Mul,
45 Div,
46 Mod,
47 BitAnd,
48 BitOr,
49 LShift,
50 RShift,
51 As,
52 Escape,
53 Custom(&'static str),
54
55 PgOperator(PgBinOper),
56
57 SqliteOperator(SqliteBinOper),
58}
59
60#[derive(Debug, Clone, PartialEq)]
62pub enum LogicalChainOper {
63 And(Expr),
64 Or(Expr),
65}
66
67#[derive(Debug, Clone, Copy, PartialEq, Eq)]
69pub enum JoinType {
70 Join,
71 CrossJoin,
72 InnerJoin,
73 LeftJoin,
74 RightJoin,
75 FullOuterJoin,
76 StraightJoin,
77}
78
79#[derive(Debug, Clone, Copy, PartialEq, Eq)]
81pub enum NullOrdering {
82 First,
83 Last,
84}
85
86#[derive(Debug, Clone, PartialEq)]
88pub struct OrderExpr {
89 pub(crate) expr: Expr,
90 pub(crate) order: Order,
91 pub(crate) nulls: Option<NullOrdering>,
92}
93
94#[derive(Debug, Clone, PartialEq)]
96pub enum JoinOn {
97 Condition(Box<ConditionHolder>),
98 Columns(Vec<Expr>),
99}
100
101#[derive(Debug, Clone, PartialEq)]
103pub enum Order {
104 Asc,
105 Desc,
106 Field(Values),
107}
108
109#[derive(Debug, Clone, PartialEq)]
113pub enum Keyword {
114 Null,
115 CurrentDate,
116 CurrentTime,
117 CurrentTimestamp,
118 Default,
119 Custom(DynIden),
120}
121
122#[derive(Debug, Clone)]
124pub struct LikeExpr {
125 pub(crate) pattern: String,
126 pub(crate) escape: Option<char>,
127}
128
129impl LikeExpr {
130 pub fn new<T>(pattern: T) -> Self
131 where
132 T: Into<String>,
133 {
134 Self {
135 pattern: pattern.into(),
136 escape: None,
137 }
138 }
139
140 pub fn escape(self, c: char) -> Self {
141 Self {
142 pattern: self.pattern,
143 escape: Some(c),
144 }
145 }
146}
147
148pub trait IntoLikeExpr: Into<LikeExpr> {
149 fn into_like_expr(self) -> LikeExpr;
150}
151
152impl<T> IntoLikeExpr for T
153where
154 T: Into<LikeExpr>,
155{
156 fn into_like_expr(self) -> LikeExpr {
157 self.into()
158 }
159}
160
161impl<T> From<T> for LikeExpr
162where
163 T: Into<String>,
164{
165 fn from(value: T) -> Self {
166 LikeExpr::new(value)
167 }
168}
169
170#[derive(Debug, Copy, Clone, PartialEq)]
172pub enum SubQueryOper {
173 Exists,
174 Any,
175 Some,
176 All,
177}