forked from vapor/postgres-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostgreSQLBinaryOperator.swift
168 lines (125 loc) · 3.83 KB
/
PostgreSQLBinaryOperator.swift
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
public enum PostgreSQLBinaryOperator: SQLBinaryOperator, Equatable {
/// See `SQLBinaryOperator`.
public static var equal: PostgreSQLBinaryOperator { return ._equal }
/// See `SQLBinaryOperator`.
public static var notEqual: PostgreSQLBinaryOperator { return ._notEqual }
/// See `SQLBinaryOperator`.
public static var greaterThan: PostgreSQLBinaryOperator { return ._greaterThan }
/// See `SQLBinaryOperator`.
public static var lessThan: PostgreSQLBinaryOperator { return ._lessThan }
/// See `SQLBinaryOperator`.
public static var greaterThanOrEqual: PostgreSQLBinaryOperator { return ._greaterThanOrEqual }
/// See `SQLBinaryOperator`.
public static var lessThanOrEqual: PostgreSQLBinaryOperator { return ._lessThanOrEqual }
/// See `SQLBinaryOperator`.
public static var like: PostgreSQLBinaryOperator { return ._like }
/// See `SQLBinaryOperator`.
public static var `in`: PostgreSQLBinaryOperator { return ._in }
/// See `SQLBinaryOperator`.
public static var `notIn`: PostgreSQLBinaryOperator { return ._notIn }
/// See `SQLBinaryOperator`.
public static var and: PostgreSQLBinaryOperator { return ._and }
/// See `SQLBinaryOperator`.
public static var or: PostgreSQLBinaryOperator { return ._or }
/// `||`
case _concatenate
/// `*`
case _multiply
/// `/`
case _divide
/// `%`
case _modulo
/// `+`
case _add
/// `-`
case _subtract
/// `<<`
case _bitwiseShiftLeft
/// `>>`
case _bitwiseShiftRight
/// `&`
case _bitwiseAnd
/// `|`
case _bitwiseOr
/// `<`
case _lessThan
/// `<=`
case _lessThanOrEqual
/// `>`
case _greaterThan
/// `>=`
case _greaterThanOrEqual
/// `=` or `==`
case _equal
/// `!=` or `<>`
case _notEqual
/// `AND`
case _and
/// `OR`
case _or
/// `IS`
case _is
/// `IS NOT`
case _isNot
/// `IN`
case _in
/// `NOT IN`
case _notIn
/// `LIKE`
case _like
/// `NOT LIKE`
case _notLike
/// `GLOB`
case _glob
/// `NOT GLOB`
case _notGlob
/// `MATCH`
case _match
/// `NOT MATCH`
case _notMatch
/// `REGEXP`
case _regexp
/// `NOT REGEXP`
case _notRegexp
/// `ILIKE`
case ilike
/// `NOT ILIKE`
case notILike
/// See `SQLSerializable`.
public func serialize(_ binds: inout [Encodable]) -> String {
switch self {
case ._add: return "+"
case ._bitwiseAnd: return "&"
case ._bitwiseOr: return "|"
case ._bitwiseShiftLeft: return "<<"
case ._bitwiseShiftRight: return ">>"
case ._concatenate: return "||"
case ._divide: return "/"
case ._equal: return "="
case ._greaterThan: return ">"
case ._greaterThanOrEqual: return ">="
case ._lessThan: return "<"
case ._lessThanOrEqual: return "<="
case ._modulo: return "%"
case ._multiply: return "*"
case ._notEqual: return "!="
case ._subtract: return "-"
case ._and: return "AND"
case ._or: return "OR"
case ._in: return "IN"
case ._notIn: return "NOT IN"
case ._is: return "IS"
case ._isNot: return "IS NOT"
case ._like: return "LIKE"
case ._glob: return "GLOB"
case ._match: return "MATCH"
case ._regexp: return "REGEXP"
case ._notLike: return "NOT LIKE"
case ._notGlob: return "NOT GLOB"
case ._notMatch: return "NOT MATCH"
case ._notRegexp: return "NOT REGEXP"
case .ilike: return "ILIKE"
case .notILike: return "NOT ILIKE"
}
}
}