1
1
-- Start transaction and plan the tests.
2
2
BEGIN ;
3
- SELECT plan(41 );
3
+ SELECT plan(44 );
4
4
5
5
create table tests (
6
6
" tid" typeid
@@ -113,6 +113,26 @@ SELECT is(
113
113
' Print valid: valid-alphabet'
114
114
);
115
115
116
+ -- - name: valid-prefix-underscores
117
+ -- typeid: "pre_fix_0123456789abcdefghjkmnpqrs"
118
+ -- prefix: "pre_fix"
119
+ -- uuid: "0110c853-1d09-52d8-d73e-1194e95b5f19"
120
+ SELECT is(
121
+ typeid_parse(' pre_fix_0123456789abcdefghjkmnpqrs' ),
122
+ (' pre_fix' , ' 0110c853-1d09-52d8-d73e-1194e95b5f19' )::typeid,
123
+ ' Parse valid: valid-prefix-underscores'
124
+ );
125
+ SELECT is(
126
+ typeid_print((' pre_fix' , ' 0110c853-1d09-52d8-d73e-1194e95b5f19' )),
127
+ ' pre_fix_0123456789abcdefghjkmnpqrs' ,
128
+ ' Print valid: valid-alphabet-underscores'
129
+ );
130
+ SELECT is(
131
+ typeid_print((' pre_____fix' , ' 0110c853-1d09-52d8-d73e-1194e95b5f19' )),
132
+ ' pre_____fix_0123456789abcdefghjkmnpqrs' ,
133
+ ' Print valid: valid-alphabet-underscores'
134
+ );
135
+
116
136
-- - name: valid-uuidv7
117
137
-- typeid: "prefix_01h455vb4pex5vsknk084sn02q"
118
138
-- prefix: "prefix"
@@ -135,13 +155,13 @@ SELECT is(
135
155
-- description: "The prefix should be lowercase with no uppercase letters"
136
156
SELECT throws_ok(
137
157
$$ INSERT into tests (tid) VALUES (typeid_parse(' PREFIX_00000000000000000000000000' )); $$,
138
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
158
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
139
159
' Parse invalid: prefix-uppercase'
140
160
);
141
161
142
162
SELECT throws_ok(
143
163
$$ INSERT into tests (tid) VALUES (typeid_generate(' PREFIX' )); $$,
144
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
164
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
145
165
' Parse invalid: prefix-uppercase'
146
166
);
147
167
@@ -150,13 +170,13 @@ SELECT throws_ok(
150
170
-- description: "The prefix can't have numbers, it needs to be alphabetic"
151
171
SELECT throws_ok(
152
172
$$ INSERT into tests (tid) VALUES (typeid_parse(' 12345_00000000000000000000000000' )); $$,
153
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
173
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
154
174
' Parse invalid: prefix-numeric'
155
175
);
156
176
157
177
SELECT throws_ok(
158
178
$$ INSERT into tests (tid) VALUES (typeid_generate(' 12345' )); $$,
159
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
179
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
160
180
' Parse invalid: prefix-numeric'
161
181
);
162
182
@@ -165,28 +185,28 @@ SELECT throws_ok(
165
185
-- description: "The prefix can't have symbols, it needs to be alphabetic"
166
186
SELECT throws_ok(
167
187
$$ INSERT into tests (tid) VALUES (typeid_parse(' pre.fix_00000000000000000000000000' )); $$,
168
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
188
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
169
189
' Parse invalid: prefix-period'
170
190
);
171
191
172
192
SELECT throws_ok(
173
193
$$ INSERT into tests (tid) VALUES (typeid_generate(' pre.fix' )); $$,
174
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
194
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
175
195
' Parse invalid: prefix-period'
176
196
);
177
197
178
198
-- - name: prefix-underscore
179
199
-- typeid: "pre_fix_00000000000000000000000000"
180
- -- description: "The prefix can't have symbols, it needs to be alphabetic "
200
+ -- description: "The prefix can't have leading or trailing underscores "
181
201
SELECT throws_ok(
182
- $$ INSERT into tests (tid) VALUES (typeid_parse( ' pre_fix_00000000000000000000000000 ' )); $$,
183
- ' typeid suffix must be 26 characters ' ,
202
+ $$ INSERT into tests (tid) VALUES (typeid_generate( ' _prefix ' )); $$,
203
+ ' typeid prefix must match the regular expression ^([a-z]([a-z_]{0,61}[a-z])?)?$ ' ,
184
204
' Parse invalid: prefix-underscore'
185
205
);
186
206
187
207
SELECT throws_ok(
188
- $$ INSERT into tests (tid) VALUES (typeid_generate(' pre_fix ' )); $$,
189
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
208
+ $$ INSERT into tests (tid) VALUES (typeid_generate(' prefix_ ' )); $$,
209
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
190
210
' Parse invalid: prefix-underscore'
191
211
);
192
212
@@ -195,13 +215,13 @@ SELECT throws_ok(
195
215
-- description: "The prefix can only have ascii letters"
196
216
SELECT throws_ok(
197
217
$$ INSERT into tests (tid) VALUES (typeid_parse(' préfix_00000000000000000000000000' )); $$,
198
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
218
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
199
219
' Parse invalid: prefix-non-ascii'
200
220
);
201
221
202
222
SELECT throws_ok(
203
223
$$ INSERT into tests (tid) VALUES (typeid_generate(' préfix' )); $$,
204
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
224
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
205
225
' Parse invalid: prefix-non-ascii'
206
226
);
207
227
@@ -210,13 +230,13 @@ SELECT throws_ok(
210
230
-- description: "The prefix can't have any spaces"
211
231
SELECT throws_ok(
212
232
$$ INSERT into tests (tid) VALUES (typeid_parse(' prefix_00000000000000000000000000' )); $$,
213
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
233
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
214
234
' Parse invalid: prefix-spaces'
215
235
);
216
236
217
237
SELECT throws_ok(
218
238
$$ INSERT into tests (tid) VALUES (typeid_generate(' prefix' )); $$,
219
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
239
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
220
240
' Parse invalid: prefix-spaces'
221
241
);
222
242
@@ -226,13 +246,13 @@ SELECT throws_ok(
226
246
-- description: "The prefix can't be 64 characters, it needs to be 63 characters or less"
227
247
SELECT throws_ok(
228
248
$$ INSERT into tests (tid) VALUES (typeid_parse(' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl_00000000000000000000000000' )); $$,
229
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
249
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
230
250
' Parse invalid: prefix-64-chars'
231
251
);
232
252
233
253
SELECT throws_ok(
234
254
$$ INSERT into tests (tid) VALUES (typeid_generate(' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' )); $$,
235
- ' typeid prefix must match the regular expression [a-z]{0,63} ' ,
255
+ ' typeid prefix must match the regular expression ^( [a-z]([a-z_] {0,61}[a-z])?)?$ ' ,
236
256
' Parse invalid: prefix-64-chars'
237
257
);
238
258
0 commit comments