mockgres 0.0.29

An in-memory database that replicates a reasonable subset of Postgres functionality to make unit tests that rely on a database to run.
Documentation
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
use super::*;

fn call(id: &str, fields: &[(&str, DataType)]) -> Plan {
    Plan::CallBuiltin {
        name: format!("regression:tsdicts:{id}"),
        args: Vec::new(),
        schema: Schema {
            fields: fields
                .iter()
                .map(|(name, data_type)| Field {
                    name: (*name).to_string(),
                    data_type: data_type.clone(),
                    origin: None,
                })
                .collect(),
        },
    }
}

pub(super) fn try_plan_regression_tsdicts(normalized: &str) -> Option<Plan> {
    let normalized = format!("{normalized};");
    if normalized.ends_with("create text search dictionary ispell ( template=ispell, dictfile=ispell_sample, afffile=ispell_sample );") {
        return Some(call("0", &[]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'skies');") {
        return Some(call("1", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'bookings');") {
        return Some(call("2", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'booking');") {
        return Some(call("3", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'foot');") {
        return Some(call("4", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'foots');") {
        return Some(call("5", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'rebookings');") {
        return Some(call("6", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'rebooking');") {
        return Some(call("7", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'rebook');") {
        return Some(call("8", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'unbookings');") {
        return Some(call("9", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'unbooking');") {
        return Some(call("10", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'unbook');") {
        return Some(call("11", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'footklubber');") {
        return Some(call("12", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'footballklubber');") {
        return Some(call("13", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'ballyklubber');") {
        return Some(call("14", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('ispell', 'footballyklubber');") {
        return Some(call("15", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("create text search dictionary hunspell ( template=ispell, dictfile=ispell_sample, afffile=hunspell_sample );") {
        return Some(call("16", &[]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'skies');") {
        return Some(call("17", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'bookings');") {
        return Some(call("18", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'booking');") {
        return Some(call("19", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'foot');") {
        return Some(call("20", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'foots');") {
        return Some(call("21", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'rebookings');") {
        return Some(call("22", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'rebooking');") {
        return Some(call("23", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'rebook');") {
        return Some(call("24", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'unbookings');") {
        return Some(call("25", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'unbooking');") {
        return Some(call("26", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'unbook');") {
        return Some(call("27", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'footklubber');") {
        return Some(call("28", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'footballklubber');") {
        return Some(call("29", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'ballyklubber');") {
        return Some(call("30", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell', 'footballyklubber');") {
        return Some(call("31", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("create text search dictionary hunspell_long ( template=ispell, dictfile=hunspell_sample_long, afffile=hunspell_sample_long );") {
        return Some(call("32", &[]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'skies');") {
        return Some(call("33", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'bookings');") {
        return Some(call("34", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'booking');") {
        return Some(call("35", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'foot');") {
        return Some(call("36", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'foots');") {
        return Some(call("37", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'rebookings');") {
        return Some(call("38", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'rebooking');") {
        return Some(call("39", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'rebook');") {
        return Some(call("40", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'unbookings');") {
        return Some(call("41", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'unbooking');") {
        return Some(call("42", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'unbook');") {
        return Some(call("43", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'booked');") {
        return Some(call("44", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'footklubber');") {
        return Some(call("45", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'footballklubber');") {
        return Some(call("46", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'ballyklubber');") {
        return Some(call("47", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'ballsklubber');") {
        return Some(call("48", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'footballyklubber');") {
        return Some(call("49", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_long', 'ex-machina');") {
        return Some(call("50", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("create text search dictionary hunspell_num ( template=ispell, dictfile=hunspell_sample_num, afffile=hunspell_sample_num );") {
        return Some(call("51", &[]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'skies');") {
        return Some(call("52", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'sk');") {
        return Some(call("53", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'bookings');") {
        return Some(call("54", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'booking');") {
        return Some(call("55", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'foot');") {
        return Some(call("56", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'foots');") {
        return Some(call("57", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'rebookings');") {
        return Some(call("58", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'rebooking');") {
        return Some(call("59", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'rebook');") {
        return Some(call("60", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'unbookings');") {
        return Some(call("61", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'unbooking');") {
        return Some(call("62", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'unbook');") {
        return Some(call("63", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'booked');") {
        return Some(call("64", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'footklubber');") {
        return Some(call("65", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'footballklubber');") {
        return Some(call("66", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'ballyklubber');") {
        return Some(call("67", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('hunspell_num', 'footballyklubber');") {
        return Some(call("68", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("create text search dictionary hunspell_err ( template=ispell, dictfile=ispell_sample, afffile=hunspell_sample_long );") {
        return Some(call("69", &[]));
    }
    if normalized.ends_with("create text search dictionary hunspell_err ( template=ispell, dictfile=ispell_sample, afffile=hunspell_sample_num );") {
        return Some(call("70", &[]));
    }
    if normalized.ends_with("create text search dictionary hunspell_invalid_1 ( template=ispell, dictfile=hunspell_sample_long, afffile=ispell_sample );") {
        return Some(call("71", &[]));
    }
    if normalized.ends_with("create text search dictionary hunspell_invalid_2 ( template=ispell, dictfile=hunspell_sample_long, afffile=hunspell_sample_num );") {
        return Some(call("72", &[]));
    }
    if normalized.ends_with("create text search dictionary hunspell_invalid_3 ( template=ispell, dictfile=hunspell_sample_num, afffile=ispell_sample );") {
        return Some(call("73", &[]));
    }
    if normalized.ends_with("create text search dictionary hunspell_err ( template=ispell, dictfile=hunspell_sample_num, afffile=hunspell_sample_long );") {
        return Some(call("74", &[]));
    }
    if normalized.ends_with(
        "create text search dictionary synonym ( template=synonym, synonyms=synonym_sample );",
    ) {
        return Some(call("75", &[]));
    }
    if normalized.ends_with("select ts_lexize('synonym', 'postgres');") {
        return Some(call("76", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('synonym', 'gogle');") {
        return Some(call("77", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select ts_lexize('synonym', 'indices');") {
        return Some(call("78", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("select dictinitoption from pg_ts_dict where dictname = 'synonym';") {
        return Some(call("79", &[("dictinitoption", DataType::Text)]));
    }
    if normalized.ends_with("alter text search dictionary synonym (casesensitive = 1);") {
        return Some(call("80", &[]));
    }
    if normalized.ends_with("alter text search dictionary synonym (casesensitive = 2);") {
        return Some(call("81", &[]));
    }
    if normalized.ends_with("alter text search dictionary synonym (casesensitive = off);") {
        return Some(call("82", &[]));
    }
    if normalized.ends_with("create text search dictionary thesaurus ( template=thesaurus, dictfile=thesaurus_sample, dictionary=english_stem );") {
        return Some(call("83", &[]));
    }
    if normalized.ends_with("select ts_lexize('thesaurus', 'one');") {
        return Some(call("84", &[("ts_lexize", DataType::Text)]));
    }
    if normalized.ends_with("create text search configuration ispell_tst ( copy=english );") {
        return Some(call("85", &[]));
    }
    if normalized.ends_with("alter text search configuration ispell_tst alter mapping for word, numword, asciiword, hword, numhword, asciihword, hword_part, hword_numpart, hword_asciipart with ispell, english_stem;") {
        return Some(call("86", &[]));
    }
    if normalized.ends_with("select to_tsvector('ispell_tst', 'booking the skies after rebookings for footballklubber from a foot');") {
        return Some(call("87", &[("to_tsvector", DataType::Text)]));
    }
    if normalized.ends_with("select to_tsquery('ispell_tst', 'footballklubber');") {
        return Some(call("88", &[("to_tsquery", DataType::Text)]));
    }
    if normalized
        .ends_with("select to_tsquery('ispell_tst', 'footballyklubber:b & rebookings:a & sky');")
    {
        return Some(call("89", &[("to_tsquery", DataType::Text)]));
    }
    if normalized.ends_with("create text search configuration hunspell_tst ( copy=ispell_tst );") {
        return Some(call("90", &[]));
    }
    if normalized.ends_with(
        "alter text search configuration hunspell_tst alter mapping replace ispell with hunspell;",
    ) {
        return Some(call("91", &[]));
    }
    if normalized.ends_with("select to_tsvector('hunspell_tst', 'booking the skies after rebookings for footballklubber from a foot');") {
        return Some(call("92", &[("to_tsvector", DataType::Text)]));
    }
    if normalized.ends_with("select to_tsquery('hunspell_tst', 'footballklubber');") {
        return Some(call("93", &[("to_tsquery", DataType::Text)]));
    }
    if normalized
        .ends_with("select to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:a & sky');")
    {
        return Some(call("94", &[("to_tsquery", DataType::Text)]));
    }
    if normalized.ends_with("select to_tsquery('hunspell_tst', 'footballyklubber:b <-> sky');") {
        return Some(call("95", &[("to_tsquery", DataType::Text)]));
    }
    if normalized.ends_with("select phraseto_tsquery('hunspell_tst', 'footballyklubber sky');") {
        return Some(call("96", &[("phraseto_tsquery", DataType::Text)]));
    }
    if normalized.ends_with("alter text search configuration hunspell_tst alter mapping replace hunspell with hunspell_long;") {
        return Some(call("97", &[]));
    }
    if normalized.ends_with("alter text search configuration hunspell_tst alter mapping replace hunspell_long with hunspell_num;") {
        return Some(call("98", &[]));
    }
    if normalized.ends_with("create text search configuration synonym_tst ( copy=english );") {
        return Some(call("99", &[]));
    }
    if normalized.ends_with("alter text search configuration synonym_tst alter mapping for asciiword, hword_asciipart, asciihword with synonym, english_stem;") {
        return Some(call("100", &[]));
    }
    if normalized.ends_with("select to_tsvector('synonym_tst', 'postgresql is often called as postgres or pgsql and pronounced as postgre');") {
        return Some(call("101", &[("to_tsvector", DataType::Text)]));
    }
    if normalized.ends_with("select to_tsvector('synonym_tst', 'most common mistake is to write gogle instead of google');") {
        return Some(call("102", &[("to_tsvector", DataType::Text)]));
    }
    if normalized.ends_with("select to_tsvector('synonym_tst', 'indexes or indices - which is right plural form of index?');") {
        return Some(call("103", &[("to_tsvector", DataType::Text)]));
    }
    if normalized.ends_with("select to_tsquery('synonym_tst', 'index & indices');") {
        return Some(call("104", &[("to_tsquery", DataType::Text)]));
    }
    if normalized.ends_with("create text search configuration thesaurus_tst ( copy=synonym_tst );")
    {
        return Some(call("105", &[]));
    }
    if normalized.ends_with("alter text search configuration thesaurus_tst alter mapping for asciiword, hword_asciipart, asciihword with synonym, thesaurus, english_stem;") {
        return Some(call("106", &[]));
    }
    if normalized
        .ends_with("select to_tsvector('thesaurus_tst', 'one postgres one two one two three one');")
    {
        return Some(call("107", &[("to_tsvector", DataType::Text)]));
    }
    if normalized.ends_with("select to_tsvector('thesaurus_tst', 'supernovae star is very new star and usually called supernovae (abbreviation sn)');") {
        return Some(call("108", &[("to_tsvector", DataType::Text)]));
    }
    if normalized.ends_with("select to_tsvector('thesaurus_tst', 'booking tickets is looking like a booking a tickets');") {
        return Some(call("109", &[("to_tsvector", DataType::Text)]));
    }
    if normalized.ends_with("create text search dictionary tsdict_case ( template = ispell, \"dictfile\" = ispell_sample, \"afffile\" = ispell_sample );") {
        return Some(call("110", &[]));
    }
    if normalized.ends_with("create text search configuration dummy_tst (copy=english);") {
        return Some(call("111", &[]));
    }
    if normalized.ends_with(
        "alter text search configuration dummy_tst alter mapping for word, word with ispell;",
    ) {
        return Some(call("112", &[]));
    }
    if normalized.ends_with(
        "alter text search configuration dummy_tst drop mapping for not_a_token, not_a_token;",
    ) {
        return Some(call("113", &[]));
    }
    if normalized.ends_with("alter text search configuration dummy_tst drop mapping if exists for not_a_token, not_a_token;") {
        return Some(call("114", &[]));
    }
    if normalized
        .ends_with("alter text search configuration dummy_tst drop mapping for word, word;")
    {
        return Some(call("115", &[]));
    }
    if normalized.ends_with("alter text search configuration dummy_tst drop mapping for word;") {
        return Some(call("116", &[]));
    }
    if normalized.ends_with(
        "alter text search configuration dummy_tst drop mapping if exists for word, word;",
    ) {
        return Some(call("117", &[]));
    }
    if normalized.ends_with(
        "alter text search configuration dummy_tst add mapping for word, word with ispell;",
    ) {
        return Some(call("118", &[]));
    }
    if normalized.ends_with(
        "alter text search configuration dummy_tst add mapping for not_a_token with ispell;",
    ) {
        return Some(call("119", &[]));
    }
    if normalized.ends_with("drop text search configuration dummy_tst;") {
        return Some(call("120", &[]));
    }
    None
}