|
1 | 1 | extension PostgreSQLQuery {
|
2 | 2 | public enum DataType {
|
3 |
| - /// int8 signed eight-byte integer |
| 3 | + /// signed eight-byte integer |
| 4 | + public static var int8: DataType { |
| 5 | + return .bigint |
| 6 | + } |
| 7 | + |
| 8 | + /// signed eight-byte integer |
4 | 9 | case bigint
|
5 |
| - /// serial8 autoincrementing eight-byte integer |
| 10 | + |
| 11 | + /// autoincrementing eight-byte integer |
| 12 | + public static var serial8: DataType { |
| 13 | + return .bigserial |
| 14 | + } |
| 15 | + |
| 16 | + /// autoincrementing eight-byte integer |
6 | 17 | case bigserial
|
| 18 | + |
| 19 | + #if swift(>=4.2) |
7 | 20 | /// fixed-length bit string
|
8 | 21 | public static var bit: DataType {
|
9 | 22 | return .bit(nil)
|
10 | 23 | }
|
| 24 | + #endif |
| 25 | + |
11 | 26 | /// fixed-length bit string
|
12 | 27 | case bit(Int?)
|
| 28 | + |
| 29 | + #if swift(>=4.2) |
| 30 | + /// variable-length bit string |
13 | 31 | public static var varbit: DataType {
|
14 | 32 | return .varbit(nil)
|
15 | 33 | }
|
| 34 | + #endif |
| 35 | + |
16 | 36 | /// variable-length bit string
|
17 | 37 | case varbit(Int?)
|
| 38 | + |
18 | 39 | /// logical Boolean (true/false)
|
19 | 40 | public static var bool: DataType {
|
20 | 41 | return .boolean
|
21 | 42 | }
|
22 |
| - /// bool logical Boolean (true/false) |
| 43 | + |
| 44 | + /// logical Boolean (true/false) |
23 | 45 | case boolean
|
| 46 | + |
24 | 47 | /// rectangular box on a plane
|
25 | 48 | case box
|
| 49 | + |
26 | 50 | /// binary data (“byte array”)
|
27 | 51 | case bytea
|
| 52 | + |
| 53 | + #if swift(>=4.2) |
28 | 54 | /// fixed-length character string
|
29 | 55 | public static var char: DataType {
|
30 | 56 | return .char(nil)
|
31 | 57 | }
|
32 |
| - /// [ (n) ] char [ (n) ] fixed-length character string |
| 58 | + #endif |
| 59 | + |
| 60 | + /// fixed-length character string |
33 | 61 | case char(Int?)
|
34 |
| - /// varying [ (n) ] varchar [ (n) ] variable-length character string |
| 62 | + |
| 63 | + #if swift(>=4.2) |
| 64 | + /// variable-length character string |
35 | 65 | public static var varchar: DataType {
|
36 | 66 | return .varchar(nil)
|
37 | 67 | }
|
38 |
| - /// varying [ (n) ] varchar [ (n) ] variable-length character string |
| 68 | + #endif |
| 69 | + |
| 70 | + /// variable-length character string |
39 | 71 | case varchar(Int?)
|
| 72 | + |
40 | 73 | /// IPv4 or IPv6 network address
|
41 | 74 | case cidr
|
| 75 | + |
42 | 76 | /// circle on a plane
|
43 | 77 | case circle
|
| 78 | + |
44 | 79 | /// calendar date (year, month, day)
|
45 | 80 | case date
|
46 |
| - /// precision float8 double precision floating-point number (8 bytes) |
| 81 | + |
| 82 | + /// floating-point number (8 bytes) |
47 | 83 | public static var float8: DataType {
|
48 | 84 | return .doublePrecision
|
49 | 85 | }
|
50 |
| - /// precision float8 double precision floating-point number (8 bytes) |
| 86 | + |
| 87 | + /// floating-point number (8 bytes) |
51 | 88 | case doublePrecision
|
| 89 | + |
52 | 90 | /// IPv4 or IPv6 host address
|
53 | 91 | case inet
|
54 |
| - /// int, int4 signed four-byte integer |
| 92 | + |
| 93 | + /// signed four-byte integer |
55 | 94 | public static var int: DataType {
|
56 | 95 | return .integer
|
57 | 96 | }
|
58 |
| - /// int, int4 signed four-byte integer |
| 97 | + |
| 98 | + /// signed four-byte integer |
59 | 99 | public static var int4: DataType {
|
60 | 100 | return .integer
|
61 | 101 | }
|
62 |
| - /// int, int4 signed four-byte integer |
| 102 | + |
| 103 | + /// signed four-byte integer |
63 | 104 | case integer
|
64 |
| - /// [ fields ] [ (p) ] time span |
| 105 | + |
| 106 | + /// time span |
65 | 107 | case interval
|
| 108 | + |
66 | 109 | /// textual JSON data
|
67 | 110 | case json
|
| 111 | + |
68 | 112 | /// binary JSON data, decomposed
|
69 | 113 | case jsonb
|
| 114 | + |
70 | 115 | /// infinite line on a plane
|
71 | 116 | case line
|
| 117 | + |
72 | 118 | /// line segment on a plane
|
73 | 119 | case lseg
|
| 120 | + |
74 | 121 | /// MAC (Media Access Control) address
|
75 | 122 | case macaddr
|
| 123 | + |
76 | 124 | /// MAC (Media Access Control) address (EUI-64 format)
|
77 | 125 | case macaddr8
|
| 126 | + |
78 | 127 | /// currency amount
|
79 | 128 | case money
|
| 129 | + |
80 | 130 | /// exact numeric of selectable precision
|
81 | 131 | public static var decimal: DataType {
|
82 | 132 | return .numeric(nil)
|
83 | 133 | }
|
| 134 | + |
84 | 135 | /// exact numeric of selectable precision
|
85 | 136 | public static func decimal(_ p: Int, _ s: Int) -> DataType {
|
86 | 137 | return .numeric((p, s))
|
87 | 138 | }
|
| 139 | + |
| 140 | + #if swift(>=4.2) |
88 | 141 | /// exact numeric of selectable precision
|
89 | 142 | public static func numeric(_ p: Int, _ s: Int) -> DataType {
|
90 | 143 | return .numeric((p, s))
|
91 | 144 | }
|
| 145 | + |
92 | 146 | /// exact numeric of selectable precision
|
93 | 147 | public static var numeric: DataType {
|
94 | 148 | return .numeric(nil)
|
95 | 149 | }
|
| 150 | + #endif |
| 151 | + |
96 | 152 | /// exact numeric of selectable precision
|
97 | 153 | case numeric((Int, Int)?)
|
| 154 | + |
98 | 155 | /// geometric path on a plane
|
99 | 156 | case path
|
| 157 | + |
100 | 158 | /// PostgreSQL Log Sequence Number
|
101 | 159 | case pgLSN
|
| 160 | + |
102 | 161 | /// geometric point on a plane
|
103 | 162 | case point
|
| 163 | + |
104 | 164 | /// closed geometric path on a plane
|
105 | 165 | case polygon
|
| 166 | + |
106 | 167 | /// single precision floating-point number (4 bytes)
|
107 | 168 | public static var float4: DataType {
|
108 | 169 | return .real
|
109 | 170 | }
|
| 171 | + |
110 | 172 | /// single precision floating-point number (4 bytes)
|
111 | 173 | case real
|
| 174 | + |
112 | 175 | /// signed two-byte integer
|
113 | 176 | public static var int2: DataType {
|
114 | 177 | return .smallint
|
115 | 178 | }
|
| 179 | + |
116 | 180 | /// signed two-byte integer
|
117 | 181 | case smallint
|
| 182 | + |
118 | 183 | /// autoincrementing two-byte integer
|
119 | 184 | public static var serial2: DataType {
|
120 | 185 | return .smallint
|
121 | 186 | }
|
| 187 | + |
122 | 188 | /// autoincrementing two-byte integer
|
123 | 189 | case smallserial
|
| 190 | + |
124 | 191 | /// autoincrementing four-byte integer
|
125 | 192 | public static var serial4: DataType {
|
126 | 193 | return .smallint
|
127 | 194 | }
|
| 195 | + |
128 | 196 | /// autoincrementing four-byte integer
|
129 | 197 | case serial
|
| 198 | + |
130 | 199 | /// variable-length character string
|
131 | 200 | case text
|
| 201 | + |
| 202 | + #if swift(>=4.2) |
132 | 203 | /// time of day (no time zone)
|
133 | 204 | public static var time: DataType {
|
134 | 205 | return .time(nil)
|
135 | 206 | }
|
| 207 | + #endif |
| 208 | + |
136 | 209 | /// time of day (no time zone)
|
137 | 210 | case time(Int?)
|
| 211 | + |
| 212 | + #if swift(>=4.2) |
138 | 213 | /// time of day, including time zone
|
139 | 214 | public static var timetz: DataType {
|
140 | 215 | return .timetz(nil)
|
141 | 216 | }
|
| 217 | + #endif |
| 218 | + |
142 | 219 | /// time of day, including time zone
|
143 | 220 | case timetz(Int?)
|
| 221 | + |
| 222 | + #if swift(>=4.2) |
144 | 223 | /// date and time (no time zone)
|
145 | 224 | public static var timestamp: DataType {
|
146 | 225 | return .timestamp(nil)
|
147 | 226 | }
|
| 227 | + #endif |
| 228 | + |
148 | 229 | /// date and time (no time zone)
|
149 | 230 | case timestamp(Int?)
|
| 231 | + |
| 232 | + #if swift(>=4.2) |
150 | 233 | /// date and time, including time zone
|
151 | 234 | public static var timestamptz: DataType {
|
152 | 235 | return .timestamptz(nil)
|
153 | 236 | }
|
| 237 | + #endif |
| 238 | + |
154 | 239 | /// date and time, including time zone
|
155 | 240 | case timestamptz(Int?)
|
| 241 | + |
156 | 242 | /// text search query
|
157 | 243 | case tsquery
|
| 244 | + |
158 | 245 | /// text search document
|
159 | 246 | case tsvector
|
| 247 | + |
160 | 248 | /// user-level transaction ID snapshot
|
161 | 249 | case txidSnapshot
|
| 250 | + |
162 | 251 | /// universally unique identifier
|
163 | 252 | case uuid
|
| 253 | + |
164 | 254 | /// XML data
|
165 | 255 | case xml
|
| 256 | + |
166 | 257 | /// User-defined type
|
167 | 258 | case custom(String)
|
168 | 259 | }
|
|
0 commit comments