forked from confluentinc/bottledwater-pg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
type_specs.rb
326 lines (247 loc) · 8.01 KB
/
type_specs.rb
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
################################################################################
### This file is automatically generated by spec/bin/generate_type_specs.rb
### It is intended to be human readable (hence being checked into Git), but
### not manually edited.
###
### This is to make it easier to maintain tests for all supported Postgres
### types, even as extensions or new Postgres versions add new types.
###
### It is invoked from spec/functional/schema_spec.rb, which defines shared
### example groups such as 'string type' that this file refers to.
################################################################################
# Arbitrary datetime to test with: first commit to Bottled Water (per Git)
# (plus invented fractional seconds to test roundtrip fidelity)
TEST_DATETIME = Time.new(2014, 12, 27, 17, 40, 15.123456, '+01:00')
shared_examples 'type specs' do
describe 'abstime' do
example('internal type not supported') {}
end
describe 'aclitem' do
example('internal type not supported') {}
end
describe 'bigint' do
include_examples 'numeric type', "bigint", 42
end
describe 'bit' do
include_examples 'bit-string type', "bit", "1110", length: 4
end
describe 'bit varying' do
include_examples 'bit-string type', "bit varying"
end
describe 'boolean' do
include_examples 'roundtrip type', "boolean", true
end
describe 'bottledwater_error_policy' do
example('internal type not supported') {}
end
describe 'box' do
include_examples 'geometric type', "box", "(3,4),(0,0)"
end
describe 'bytea' do
include_examples 'binary type', "bytea"
end
describe '"char"' do
example('internal type not supported') {}
end
describe 'character' do
include_examples 'string type', "character", "We can handle unicode: ☃", length: 24
end
describe 'character varying' do
include_examples 'string type', "character varying", "We can handle unicode: ☃"
end
describe 'cid' do
example('internal type not supported') {}
end
describe 'cidr' do
include_examples 'roundtrip type', "cidr", "192.168.1.0/24"
end
describe 'circle' do
include_examples 'geometric type', "circle", "<(1,2),5>"
end
describe 'date' do
include_examples "date", TEST_DATETIME.to_date
end
describe 'daterange' do
include_examples 'roundtrip type', "daterange", "[1837-06-20,1901-01-22)"
end
describe 'double precision' do
include_examples 'numeric type', "double precision", 42
end
describe 'ghstore' do
example('internal type not supported') {}
end
describe 'gtsvector' do
example('internal type not supported') {}
end
describe 'hstore' do
include_examples 'roundtrip type', "hstore", '"pid"=>"2634", "service"=>"bottledwater"'
end
describe 'inet' do
include_examples 'roundtrip type', "inet", "192.168.1.1/24"
end
describe 'int2vector' do
example('internal type not supported') {}
end
describe 'int4range' do
include_examples 'roundtrip type', "int4range", "[1,5)"
end
describe 'int8range' do
include_examples 'roundtrip type', "int8range", "[1,5)"
end
describe 'integer' do
include_examples 'numeric type', "integer", 42
end
describe 'interval' do
include_examples 'interval type', "interval", "01:23:45.123456"
end
describe 'json' do
include_examples 'JSON type', "json", {"service"=>"bottledwater", "pid"=>2634}
end
describe 'jsonb' do
include_examples 'JSON type', "jsonb", {"service"=>"bottledwater", "pid"=>2634}
end
describe 'line' do
include_examples 'geometric type', "line", "{3,4,5}"
end
describe 'lseg' do
include_examples 'geometric type', "lseg", "[(0,0),(3,4)]"
end
describe 'macaddr' do
include_examples 'roundtrip type', "macaddr", '08:00:2b:01:02:03'
end
describe 'money' do
before :example do
known_bug "multiplied by 100", "https://github.com/confluentinc/bottledwater-pg/issues/60"
end
include_examples 'numeric type', "money", 42
end
describe 'name' do
example('internal type not supported') {}
end
describe 'numeric' do
before :example do
known_bug "replaced by zero", "https://github.com/confluentinc/bottledwater-pg/issues/4"
end
include_examples 'numeric type', "numeric", 42
end
describe 'numrange' do
include_examples 'roundtrip type', "numrange", "[1,5)"
end
describe 'oid' do
include_examples 'numeric type', "oid", 42
end
describe 'oidvector' do
example('internal type not supported') {}
end
describe 'path' do
include_examples 'geometric type', "path", "((1,2),(0,0),(3,4))"
end
describe 'pg_lsn' do
include_examples 'roundtrip type', "pg_lsn", '42/BEEFCAFE'
end
describe 'pg_node_tree' do
example('internal type not supported') {}
end
describe 'point' do
include_examples 'geometric type', "point", "(3,4)"
end
describe 'polygon' do
include_examples 'geometric type', "polygon", "((1,2),(0,0),(3,4))"
end
describe 'real' do
include_examples 'numeric type', "real", 42
end
describe 'refcursor' do
example('internal type not supported') {}
end
describe 'regclass' do
example('internal type not supported') {}
end
describe 'regconfig' do
example('internal type not supported') {}
end
describe 'regdictionary' do
example('internal type not supported') {}
end
describe 'regnamespace' do
example('internal type not supported') {}
end
describe 'regoper' do
example('internal type not supported') {}
end
describe 'regoperator' do
example('internal type not supported') {}
end
describe 'regproc' do
example('internal type not supported') {}
end
describe 'regprocedure' do
example('internal type not supported') {}
end
describe 'regrole' do
example('internal type not supported') {}
end
describe 'regtype' do
example('internal type not supported') {}
end
describe 'reltime' do
example('internal type not supported') {}
end
describe 'smallint' do
include_examples 'numeric type', "smallint", 42
end
describe 'smgr' do
example('internal type not supported') {}
end
describe 'text' do
include_examples 'string type', "text", "We can handle unicode: ☃"
end
describe 'tid' do
example('internal type not supported') {}
end
describe 'timestamp without time zone' do
include_examples "timestamp without time zone", TEST_DATETIME
end
describe 'timestamp with time zone' do
include_examples "timestamp with time zone", TEST_DATETIME
end
describe 'time without time zone' do
include_examples "time without time zone", TEST_DATETIME
end
describe 'time with time zone' do
include_examples "time with time zone", TEST_DATETIME
end
describe 'tinterval' do
example('internal type not supported') {}
end
describe 'tsquery' do
# tsquery can't be in a primary key because it can't be indexed directly
include_examples 'roundtrip type', "tsquery", "'fat':AB & ( 'cat' | 'postgres':* )", as_key: false
end
describe 'tsrange' do
include_examples 'roundtrip type', "tsrange", "[\"1837-06-20 00:00:00\",\"1901-01-22 00:00:00\")"
end
describe 'tstzrange' do
include_examples 'roundtrip type', "tstzrange", "[\"1837-06-20 00:00:00+00\",\"1901-01-22 00:00:00+00\")"
end
describe 'tsvector' do
# tsvector can't be in a primary key because it can't be indexed directly
include_examples 'roundtrip type', "tsvector", "'brown':3 'fox':4 'quick':2", as_key: false
end
describe 'txid_snapshot' do
example('internal type not supported') {}
end
describe 'unknown' do
example('internal type not supported') {}
end
describe 'uuid' do
include_examples 'roundtrip type', "uuid", 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'
end
describe 'xid' do
example('internal type not supported') {}
end
describe 'xml' do
# xml can't be in a primary key because it can't be indexed directly
include_examples 'roundtrip type', "xml", "<person name=\"Abraham Lincoln\"><occupations><occupation title=\"President\" /></occupations></person>", as_key: false
end
end