@pgpm/inflection 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +22 -0
  2. package/Makefile +6 -0
  3. package/README.md +5 -0
  4. package/__tests__/inflection.test.ts +181 -0
  5. package/deploy/schemas/inflection/procedures/camel.sql +25 -0
  6. package/deploy/schemas/inflection/procedures/dashed.sql +29 -0
  7. package/deploy/schemas/inflection/procedures/no_consecutive_caps.sql +53 -0
  8. package/deploy/schemas/inflection/procedures/no_single_underscores.sql +70 -0
  9. package/deploy/schemas/inflection/procedures/pascal.sql +20 -0
  10. package/deploy/schemas/inflection/procedures/pg_slugify.sql +68 -0
  11. package/deploy/schemas/inflection/procedures/plural.sql +31 -0
  12. package/deploy/schemas/inflection/procedures/should_skip_uncountable.sql +17 -0
  13. package/deploy/schemas/inflection/procedures/singular.sql +31 -0
  14. package/deploy/schemas/inflection/procedures/slugify.sql +59 -0
  15. package/deploy/schemas/inflection/procedures/uncountable_words.sql +14 -0
  16. package/deploy/schemas/inflection/procedures/underscore.sql +52 -0
  17. package/deploy/schemas/inflection/schema.sql +15 -0
  18. package/deploy/schemas/inflection/tables/inflection_rules/fixtures/1589249334312_fixture.sql +129 -0
  19. package/deploy/schemas/inflection/tables/inflection_rules/indexes/inflection_rules_type_idx.sql +12 -0
  20. package/deploy/schemas/inflection/tables/inflection_rules/table.sql +16 -0
  21. package/jest.config.js +15 -0
  22. package/launchql-inflection.control +8 -0
  23. package/launchql.plan +20 -0
  24. package/package.json +28 -0
  25. package/revert/schemas/inflection/procedures/camel.sql +7 -0
  26. package/revert/schemas/inflection/procedures/dashed.sql +7 -0
  27. package/revert/schemas/inflection/procedures/no_consecutive_caps.sql +7 -0
  28. package/revert/schemas/inflection/procedures/no_single_underscores.sql +7 -0
  29. package/revert/schemas/inflection/procedures/pascal.sql +7 -0
  30. package/revert/schemas/inflection/procedures/pg_slugify.sql +8 -0
  31. package/revert/schemas/inflection/procedures/plural.sql +7 -0
  32. package/revert/schemas/inflection/procedures/should_skip_uncountable.sql +7 -0
  33. package/revert/schemas/inflection/procedures/singular.sql +7 -0
  34. package/revert/schemas/inflection/procedures/slugify.sql +8 -0
  35. package/revert/schemas/inflection/procedures/uncountable_words.sql +7 -0
  36. package/revert/schemas/inflection/procedures/underscore.sql +7 -0
  37. package/revert/schemas/inflection/schema.sql +7 -0
  38. package/revert/schemas/inflection/tables/inflection_rules/fixtures/1589249334312_fixture.sql +5 -0
  39. package/revert/schemas/inflection/tables/inflection_rules/indexes/inflection_rules_type_idx.sql +7 -0
  40. package/revert/schemas/inflection/tables/inflection_rules/table.sql +7 -0
  41. package/sql/launchql-inflection--0.4.7.sql +451 -0
  42. package/verify/schemas/inflection/procedures/camel.sql +7 -0
  43. package/verify/schemas/inflection/procedures/dashed.sql +7 -0
  44. package/verify/schemas/inflection/procedures/no_consecutive_caps.sql +7 -0
  45. package/verify/schemas/inflection/procedures/no_single_underscores.sql +7 -0
  46. package/verify/schemas/inflection/procedures/pascal.sql +7 -0
  47. package/verify/schemas/inflection/procedures/pg_slugify.sql +7 -0
  48. package/verify/schemas/inflection/procedures/plural.sql +7 -0
  49. package/verify/schemas/inflection/procedures/should_skip_uncountable.sql +7 -0
  50. package/verify/schemas/inflection/procedures/singular.sql +7 -0
  51. package/verify/schemas/inflection/procedures/slugify.sql +7 -0
  52. package/verify/schemas/inflection/procedures/uncountable_words.sql +7 -0
  53. package/verify/schemas/inflection/procedures/underscore.sql +7 -0
  54. package/verify/schemas/inflection/schema.sql +7 -0
  55. package/verify/schemas/inflection/tables/inflection_rules/fixtures/1589249334312_fixture.sql +5 -0
  56. package/verify/schemas/inflection/tables/inflection_rules/indexes/inflection_rules_type_idx.sql +7 -0
  57. package/verify/schemas/inflection/tables/inflection_rules/table.sql +7 -0
@@ -0,0 +1,451 @@
1
+ \echo Use "CREATE EXTENSION launchql-inflection" to load this file. \quit
2
+ CREATE SCHEMA inflection;
3
+
4
+ GRANT USAGE ON SCHEMA inflection TO PUBLIC;
5
+
6
+ ALTER DEFAULT PRIVILEGES IN SCHEMA inflection
7
+ GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
8
+
9
+ CREATE FUNCTION inflection.no_consecutive_caps_till_end(str text) RETURNS text AS $EOFCODE$
10
+ DECLARE
11
+ result text[];
12
+ temp text;
13
+ BEGIN
14
+ FOR result IN
15
+ SELECT regexp_matches(str, E'([A-Z])([A-Z]+$)', 'g')
16
+ LOOP
17
+ temp = result[1] || lower(result[2]);
18
+ str = replace(str, result[1] || result[2], temp);
19
+ END LOOP;
20
+ return str;
21
+ END;
22
+ $EOFCODE$ LANGUAGE plpgsql STABLE;
23
+
24
+ CREATE FUNCTION inflection.no_consecutive_caps_till_lower(str text) RETURNS text AS $EOFCODE$
25
+ DECLARE
26
+ result text[];
27
+ temp text;
28
+ BEGIN
29
+ FOR result IN
30
+ SELECT regexp_matches(str, E'([A-Z])([A-Z]+)[A-Z][a-z]', 'g')
31
+ LOOP
32
+ temp = result[1] || lower(result[2]);
33
+ str = replace(str, result[1] || result[2], temp);
34
+ END LOOP;
35
+
36
+ return str;
37
+ END;
38
+ $EOFCODE$ LANGUAGE plpgsql STABLE;
39
+
40
+ CREATE FUNCTION inflection.no_consecutive_caps(str text) RETURNS text AS $EOFCODE$
41
+ select inflection.no_consecutive_caps_till_lower(inflection.no_consecutive_caps_till_end(str));
42
+ $EOFCODE$ LANGUAGE sql STABLE;
43
+
44
+ CREATE FUNCTION inflection.pg_slugify(value text, allow_unicode boolean) RETURNS text AS $EOFCODE$
45
+ WITH normalized AS (
46
+ SELECT
47
+ CASE WHEN allow_unicode THEN
48
+ value
49
+ ELSE
50
+ unaccent (value)
51
+ END AS value
52
+ ),
53
+ no_consecutive_caps AS (
54
+ SELECT
55
+ inflection.no_consecutive_caps (value) AS value
56
+ FROM
57
+ normalized
58
+ ),
59
+ remove_chars AS (
60
+ SELECT
61
+ regexp_replace(value, E'[^\\w\\s-]', '', 'gi') AS value
62
+ FROM
63
+ no_consecutive_caps
64
+ ),
65
+ trimmed AS (
66
+ SELECT
67
+ trim(value) AS value
68
+ FROM
69
+ remove_chars
70
+ ),
71
+ hyphenated AS (
72
+ SELECT
73
+ regexp_replace(value, E'[-\\s]+', '-', 'gi') AS value
74
+ FROM
75
+ trimmed
76
+ ),
77
+ underscored AS (
78
+ SELECT
79
+ regexp_replace(value, E'[-]+', '_', 'gi') AS value
80
+ FROM
81
+ hyphenated
82
+ ),
83
+ removedups AS (
84
+ SELECT
85
+ regexp_replace(value, E'[_]+', '_', 'gi') AS value
86
+ FROM
87
+ underscored
88
+ )
89
+ SELECT
90
+ value
91
+ FROM
92
+ removedups;
93
+ $EOFCODE$ LANGUAGE sql STRICT IMMUTABLE;
94
+
95
+ CREATE FUNCTION inflection.pg_slugify(text) RETURNS text AS $EOFCODE$SELECT inflection.pg_slugify($1, false)$EOFCODE$ LANGUAGE sql IMMUTABLE;
96
+
97
+ CREATE FUNCTION inflection.no_single_underscores_in_beginning(str text) RETURNS text AS $EOFCODE$
98
+ DECLARE
99
+ result text[];
100
+ temp text;
101
+ BEGIN
102
+ FOR result IN
103
+ SELECT regexp_matches(str, E'(^[a-z])(_)', 'g')
104
+ LOOP
105
+ str = replace(str, result[1] || result[2], result[1]);
106
+ END LOOP;
107
+ return str;
108
+ END;
109
+ $EOFCODE$ LANGUAGE plpgsql STABLE;
110
+
111
+ CREATE FUNCTION inflection.no_single_underscores_at_end(str text) RETURNS text AS $EOFCODE$
112
+ DECLARE
113
+ result text[];
114
+ temp text;
115
+ BEGIN
116
+ FOR result IN
117
+ SELECT regexp_matches(str, E'(_)([a-z]$)', 'g')
118
+ LOOP
119
+ str = replace(str, result[1] || result[2], result[2]);
120
+ END LOOP;
121
+
122
+ return str;
123
+ END;
124
+ $EOFCODE$ LANGUAGE plpgsql STABLE;
125
+
126
+ CREATE FUNCTION inflection.no_single_underscores_in_middle(str text) RETURNS text AS $EOFCODE$
127
+ DECLARE
128
+ result text[];
129
+ temp text;
130
+ BEGIN
131
+ FOR result IN
132
+ SELECT regexp_matches(str, E'(_)([a-z]_)', 'g')
133
+ LOOP
134
+ str = replace(str, result[1] || result[2], result[2]);
135
+ END LOOP;
136
+
137
+ return str;
138
+ END;
139
+ $EOFCODE$ LANGUAGE plpgsql STABLE;
140
+
141
+ CREATE FUNCTION inflection.no_single_underscores(str text) RETURNS text AS $EOFCODE$
142
+ select
143
+ inflection.no_single_underscores_in_middle(inflection.no_single_underscores_at_end(inflection.no_single_underscores_in_beginning(str)));
144
+ $EOFCODE$ LANGUAGE sql STABLE;
145
+
146
+ CREATE FUNCTION inflection.underscore(str text) RETURNS text AS $EOFCODE$
147
+ WITH slugged AS (
148
+ SELECT
149
+ inflection.pg_slugify(str) AS value
150
+ ),
151
+ convertedupper AS (
152
+ SELECT
153
+ lower(regexp_replace(value, E'([A-Z])', E'\_\\1', 'g')) AS value
154
+ FROM
155
+ slugged
156
+ ),
157
+ noprefix AS (
158
+ SELECT
159
+ regexp_replace(value, E'^_', '', 'g') AS value
160
+ FROM
161
+ convertedupper
162
+ ),
163
+ removedups AS (
164
+ SELECT
165
+ regexp_replace(value, E'[_]+', '_', 'gi') AS value
166
+ FROM
167
+ noprefix
168
+ ),
169
+ stripedges AS (
170
+ SELECT
171
+ regexp_replace(regexp_replace(value, E'([A-Z])_$', E'\\1', 'gi'), E'^_([A-Z])', E'\\1', 'gi') AS value
172
+ FROM
173
+ removedups
174
+ ),
175
+ nosingles AS (
176
+ SELECT
177
+ inflection.no_single_underscores(value) AS value
178
+ FROM
179
+ stripedges
180
+ )
181
+ SELECT
182
+ value
183
+ FROM
184
+ nosingles;
185
+ $EOFCODE$ LANGUAGE sql IMMUTABLE;
186
+
187
+ CREATE FUNCTION inflection.camel(str text) RETURNS text AS $EOFCODE$
188
+ DECLARE
189
+ result text[];
190
+ BEGIN
191
+ str = inflection.underscore(str);
192
+ FOR result IN
193
+ SELECT regexp_matches(str, E'(_[a-zA-Z0-9])', 'g')
194
+ LOOP
195
+ str = replace(str, result[1], upper(result[1]));
196
+ END LOOP;
197
+ return regexp_replace(substring(str FROM 1 FOR 1) || substring(str FROM 2 FOR length(str)), E'[_]+', '', 'gi');
198
+ END;
199
+ $EOFCODE$ LANGUAGE plpgsql STABLE;
200
+
201
+ CREATE FUNCTION inflection.dashed(str text) RETURNS text AS $EOFCODE$
202
+ WITH underscored AS (
203
+ SELECT
204
+ inflection.underscore(str) AS value
205
+ ),
206
+ dashes AS (
207
+ SELECT
208
+ regexp_replace(value, '_', '-', 'gi') AS value
209
+ FROM
210
+ underscored
211
+ )
212
+ SELECT
213
+ value
214
+ FROM
215
+ dashes;
216
+ $EOFCODE$ LANGUAGE sql IMMUTABLE;
217
+
218
+ CREATE FUNCTION inflection.pascal(str text) RETURNS text AS $EOFCODE$
219
+ DECLARE
220
+ result text[];
221
+ BEGIN
222
+ str = inflection.camel(str);
223
+ return upper(substring(str FROM 1 FOR 1)) || substring(str FROM 2 FOR length(str));
224
+ END;
225
+ $EOFCODE$ LANGUAGE plpgsql STABLE;
226
+
227
+ CREATE TABLE inflection.inflection_rules (
228
+ id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
229
+ type text,
230
+ test text,
231
+ replacement text
232
+ );
233
+
234
+ GRANT SELECT ON inflection.inflection_rules TO PUBLIC;
235
+
236
+ CREATE FUNCTION inflection.plural(str text) RETURNS text AS $EOFCODE$
237
+ DECLARE
238
+ result record;
239
+ matches text[];
240
+ BEGIN
241
+ FOR result IN
242
+ SELECT * FROM inflection.inflection_rules where type='plural'
243
+ LOOP
244
+ matches = regexp_matches(str, result.test, 'gi');
245
+ IF (array_length(matches, 1) > 0) THEN
246
+ IF (result.replacement IS NULL) THEN
247
+ return str;
248
+ END IF;
249
+ str = regexp_replace(str, result.test, result.replacement, 'gi');
250
+ return str;
251
+ END IF;
252
+ END LOOP;
253
+ return str;
254
+ END;
255
+ $EOFCODE$ LANGUAGE plpgsql IMMUTABLE;
256
+
257
+ CREATE FUNCTION inflection.uncountable_words() RETURNS text[] AS $EOFCODE$
258
+ select ARRAY[ 'accommodation', 'adulthood', 'advertising', 'advice', 'aggression', 'aid', 'air', 'aircraft', 'alcohol', 'anger', 'applause', 'arithmetic', 'assistance', 'athletics', 'bacon', 'baggage', 'beef', 'biology', 'blood', 'botany', 'bread', 'butter', 'carbon', 'cardboard', 'cash', 'chalk', 'chaos', 'chess', 'crossroads', 'countryside', 'dancing', 'deer', 'dignity', 'dirt', 'dust', 'economics', 'education', 'electricity', 'engineering', 'enjoyment', 'envy', 'equipment', 'ethics', 'evidence', 'evolution', 'fame', 'fiction', 'flour', 'flu', 'food', 'fuel', 'fun', 'furniture', 'gallows', 'garbage', 'garlic', 'genetics', 'gold', 'golf', 'gossip', 'grammar', 'gratitude', 'grief', 'guilt', 'gymnastics', 'happiness', 'hardware', 'harm', 'hate', 'hatred', 'health', 'heat', 'help', 'homework', 'honesty', 'honey', 'hospitality', 'housework', 'humour', 'hunger', 'hydrogen', 'ice', 'importance', 'inflation', 'information', 'innocence', 'iron', 'irony', 'jam', 'jewelry', 'judo', 'karate', 'knowledge', 'lack', 'laughter', 'lava', 'leather', 'leisure', 'lightning', 'linguine', 'linguini', 'linguistics', 'literature', 'litter', 'livestock', 'logic', 'loneliness', 'luck', 'luggage', 'macaroni', 'machinery', 'magic', 'management', 'mankind', 'marble', 'mathematics', 'mayonnaise', 'measles', 'methane', 'milk', 'minus', 'money', 'mud', 'music', 'mumps', 'nature', 'news', 'nitrogen', 'nonsense', 'nurture', 'nutrition', 'obedience', 'obesity', 'oxygen', 'pasta', 'patience', 'physics', 'poetry', 'pollution', 'poverty', 'pride', 'psychology', 'publicity', 'punctuation', 'quartz', 'racism', 'relaxation', 'reliability', 'research', 'respect', 'revenge', 'rice', 'rubbish', 'rum', 'safety', 'scenery', 'seafood', 'seaside', 'series', 'shame', 'sheep', 'shopping', 'sleep', 'smoke', 'smoking', 'snow', 'soap', 'software', 'soil', 'spaghetti', 'species', 'steam', 'stuff', 'stupidity', 'sunshine', 'symmetry', 'tennis', 'thirst', 'thunder', 'timber', 'traffic', 'transportation', 'trust', 'underwear', 'unemployment', 'unity', 'validity', 'veal', 'vegetation', 'vegetarianism', 'vengeance', 'violence', 'vitality', 'warmth', 'wealth', 'weather', 'welfare', 'wheat', 'wildlife', 'wisdom', 'yoga', 'zinc', 'zoology' ];
259
+ $EOFCODE$ LANGUAGE sql IMMUTABLE;
260
+
261
+ CREATE FUNCTION inflection.should_skip_uncountable(str text) RETURNS boolean AS $EOFCODE$
262
+ SELECT
263
+ str = ANY (inflection.uncountable_words ());
264
+ $EOFCODE$ LANGUAGE sql IMMUTABLE;
265
+
266
+ CREATE FUNCTION inflection.singular(str text) RETURNS text AS $EOFCODE$
267
+ DECLARE
268
+ result record;
269
+ matches text[];
270
+ BEGIN
271
+ FOR result IN
272
+ SELECT * FROM inflection.inflection_rules where type='singular'
273
+ LOOP
274
+ matches = regexp_matches(str, result.test, 'gi');
275
+ IF (array_length(matches, 1) > 0) THEN
276
+ IF (result.replacement IS NULL) THEN
277
+ return str;
278
+ END IF;
279
+ str = regexp_replace(str, result.test, result.replacement, 'gi');
280
+ return str;
281
+ END IF;
282
+ END LOOP;
283
+ return str;
284
+ END;
285
+ $EOFCODE$ LANGUAGE plpgsql IMMUTABLE;
286
+
287
+ CREATE FUNCTION inflection.slugify(value text, allow_unicode boolean) RETURNS text AS $EOFCODE$
288
+ WITH normalized AS (
289
+ SELECT
290
+ CASE WHEN allow_unicode THEN
291
+ value
292
+ ELSE
293
+ unaccent (value)
294
+ END AS value
295
+ ),
296
+ remove_chars AS (
297
+ SELECT
298
+ regexp_replace(value, E'[^\\w\\s-]', '', 'gi') AS value
299
+ FROM
300
+ normalized
301
+ ),
302
+ lowercase AS (
303
+ SELECT
304
+ lower(value) AS value
305
+ FROM
306
+ remove_chars
307
+ ),
308
+ trimmed AS (
309
+ SELECT
310
+ trim(value) AS value
311
+ FROM
312
+ lowercase
313
+ ),
314
+ hyphenated AS (
315
+ SELECT
316
+ regexp_replace(value, E'[-\\s]+', '-', 'gi') AS value
317
+ FROM
318
+ trimmed
319
+ )
320
+ SELECT
321
+ value
322
+ FROM
323
+ hyphenated;
324
+ $EOFCODE$ LANGUAGE sql STRICT IMMUTABLE;
325
+
326
+ CREATE FUNCTION inflection.slugify(text) RETURNS text AS $EOFCODE$SELECT inflection.slugify($1, false)$EOFCODE$ LANGUAGE sql IMMUTABLE;
327
+
328
+ INSERT INTO inflection.inflection_rules (
329
+ type,
330
+ test,
331
+ replacement
332
+ ) VALUES
333
+ ('plural', '^(m|wom)en$', NULL),
334
+ ('plural', '(pe)ople$', NULL),
335
+ ('plural', '(child)ren$', NULL),
336
+ ('plural', '([ti])a$', NULL),
337
+ ('plural', '((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$', NULL),
338
+ ('plural', '(hi|ti)ves$', NULL),
339
+ ('plural', '(curve)s$', NULL),
340
+ ('plural', '([lr])ves$', NULL),
341
+ ('plural', '([^fo])ves$', NULL),
342
+ ('plural', '([^aeiouy]|qu)ies$', NULL),
343
+ ('plural', '(s)eries$', NULL),
344
+ ('plural', '(m)ovies$', NULL),
345
+ ('plural', '(x|ch|ss|sh)es$', NULL),
346
+ ('plural', '([m|l])ice$', NULL),
347
+ ('plural', '(bus)es$', NULL),
348
+ ('plural', '(o)es$', NULL),
349
+ ('plural', '(shoe)s$', NULL),
350
+ ('plural', '(cris|ax|test)es$', NULL),
351
+ ('plural', '(octop|vir)i$', NULL),
352
+ ('plural', '(alias|canvas|status|campus)es$', NULL),
353
+ ('plural', '^(summons)es$', NULL),
354
+ ('plural', '^(ox)en', NULL),
355
+ ('plural', '(matr)ices$', NULL),
356
+ ('plural', '^feet$', NULL),
357
+ ('plural', '^teeth$', NULL),
358
+ ('plural', '^geese$', NULL),
359
+ ('plural', '(quiz)zes$', NULL),
360
+ ('plural', '^(whereas)es$', NULL),
361
+ ('plural', '^(criteri)a$', NULL),
362
+ ('plural', '^genera$', NULL),
363
+ ('plural', '^(m|wom)an$', E'\\1en'),
364
+ ('plural', '(pe)rson$', E'\\1ople'),
365
+ ('plural', '(child)$', E'\\1ren'),
366
+ ('plural', '^(ox)$', E'\\1en'),
367
+ ('plural', '(ax|test)is$', E'\\1es'),
368
+ ('plural', '(octop|vir)us$', E'\\1i'),
369
+ ('plural', '(alias|status|canvas|campus)$', E'\\1es'),
370
+ ('plural', '^(summons)$', E'\\1es'),
371
+ ('plural', '(bu)s$', E'\\1ses'),
372
+ ('plural', '(buffal|tomat|potat)o$', E'\\1oes'),
373
+ ('plural', '([ti])um$', E'\\1a'),
374
+ ('plural', 'sis$', 'ses'),
375
+ ('plural', '(?:([^f])fe|([lr])f)$', E'\\1\\2ves'),
376
+ ('plural', '(hi|ti)ve$', E'\\1ves'),
377
+ ('plural', '([^aeiouy]|qu)y$', E'\\1ies'),
378
+ ('plural', '(matr)ix$', E'\\1ices'),
379
+ ('plural', '(vert|ind)ex$', E'\\1ices'),
380
+ ('plural', '(x|ch|ss|sh)$', E'\\1es'),
381
+ ('plural', '([m|l])ouse$', E'\\1ice'),
382
+ ('plural', '^foot$', 'feet'),
383
+ ('plural', '^tooth$', 'teeth'),
384
+ ('plural', '^goose$', 'geese'),
385
+ ('plural', '(quiz)$', E'\\1zes'),
386
+ ('plural', '^(whereas)$', E'\\1es'),
387
+ ('plural', '^(criteri)on$', E'\\1a'),
388
+ ('plural', '^genus$', 'genera'),
389
+ ('plural', 's$', 's'),
390
+ ('plural', '$', 's'),
391
+ ('singular', '^(m|wom)an$', NULL),
392
+ ('singular', '(pe)rson$', NULL),
393
+ ('singular', '(child)$', NULL),
394
+ ('singular', '^(ox)$', NULL),
395
+ ('singular', '(ax|test)is$', NULL),
396
+ ('singular', '(octop|vir)us$', NULL),
397
+ ('singular', '(alias|status|canvas|campus)$', NULL),
398
+ ('singular', '^(summons)$', NULL),
399
+ ('singular', '(bu)s$', NULL),
400
+ ('singular', '(buffal|tomat|potat)o$', NULL),
401
+ ('singular', '([ti])um$', NULL),
402
+ ('singular', 'sis$', NULL),
403
+ ('singular', '(?:([^f])fe|([lr])f)$', NULL),
404
+ ('singular', '(hi|ti)ve$', NULL),
405
+ ('singular', '([^aeiouy]|qu)y$', NULL),
406
+ ('singular', '(x|ch|ss|sh)$', NULL),
407
+ ('singular', '(matr)ix$', NULL),
408
+ ('singular', '([m|l])ouse$', NULL),
409
+ ('singular', '^foot$', NULL),
410
+ ('singular', '^tooth$', NULL),
411
+ ('singular', '^goose$', NULL),
412
+ ('singular', '(quiz)$', NULL),
413
+ ('singular', '^(whereas)$', NULL),
414
+ ('singular', '^(criteri)on$', NULL),
415
+ ('singular', '^genus$', NULL),
416
+ ('singular', '^(m|wom)en$', E'\\1an'),
417
+ ('singular', '(pe)ople$', E'\\1rson'),
418
+ ('singular', '(child)ren$', E'\\1'),
419
+ ('singular', '^genera$', 'genus'),
420
+ ('singular', '^(criteri)a$', E'\\1on'),
421
+ ('singular', '([ti])a$', E'\\1um'),
422
+ ('singular', '((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$', E'\\1\\2sis'),
423
+ ('singular', '(hi|ti)ves$', E'\\1ve'),
424
+ ('singular', '(curve)s$', E'\\1'),
425
+ ('singular', '([lr])ves$', E'\\1f'),
426
+ ('singular', '([a])ves$', E'\\1ve'),
427
+ ('singular', '([^fo])ves$', E'\\1fe'),
428
+ ('singular', '(m)ovies$', E'\\1ovie'),
429
+ ('singular', '([^aeiouy]|qu)ies$', E'\\1y'),
430
+ ('singular', '(s)eries$', E'\\1eries'),
431
+ ('singular', '(x|ch|ss|sh)es$', E'\\1'),
432
+ ('singular', '([m|l])ice$', E'\\1ouse'),
433
+ ('singular', '(bus)es$', E'\\1'),
434
+ ('singular', '(o)es$', E'\\1'),
435
+ ('singular', '(shoe)s$', E'\\1'),
436
+ ('singular', '(cris|ax|test)es$', E'\\1is'),
437
+ ('singular', '(octop|vir)i$', E'\\1us'),
438
+ ('singular', '(alias|canvas|status|campus)es$', E'\\1'),
439
+ ('singular', '^(summons)es$', E'\\1'),
440
+ ('singular', '^(ox)en', E'\\1'),
441
+ ('singular', '(matr)ices$', E'\\1ix'),
442
+ ('singular', '(vert|ind)ices$', E'\\1ex'),
443
+ ('singular', '^feet$', 'foot'),
444
+ ('singular', '^teeth$', 'tooth'),
445
+ ('singular', '^geese$', 'goose'),
446
+ ('singular', '(quiz)zes$', E'\\1'),
447
+ ('singular', '^(whereas)es$', E'\\1'),
448
+ ('singular', 'ss$', 'ss'),
449
+ ('singular', 's$', '');
450
+
451
+ CREATE INDEX inflection_rules_type_idx ON inflection.inflection_rules (type);
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/camel on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.camel');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/dashed on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.dashed');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/no_consecutive_caps on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.no_consecutive_caps');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/no_single_underscores on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.no_single_underscores');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/pascal on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.pascal');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/pg_slugify on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.pg_slugify');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/plural on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.plural');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/should_skip_uncountable on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.should_skip_uncountable');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/singular on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.singular');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/slugify on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.slugify');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/uncountable_words on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.uncountable_words');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/procedures/underscore on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_function ('inflection.underscore');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/schema on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_schema ('inflection');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,5 @@
1
+ -- Verify schemas/inflection/tables/inflection_rules/fixtures/1589249334312_fixture on pg
2
+
3
+ BEGIN;
4
+
5
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/tables/inflection_rules/indexes/inflection_rules_type_idx on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_index ('inflection.inflection_rules', 'inflection_rules_type_idx');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/inflection/tables/inflection_rules/table on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_table ('inflection.inflection_rules');
6
+
7
+ ROLLBACK;