pqb 0.3.6 → 0.3.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pqb",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Postgres query builder",
5
5
  "homepage": "https://porm.netlify.app/guide/query-builder.html",
6
6
  "repository": {
@@ -50,7 +50,7 @@
50
50
  "dotenv": "^16.0.1",
51
51
  "jest": "^28.1.2",
52
52
  "pg": "^8.7.3",
53
- "pg-transactional-tests": "^1.0.3",
53
+ "pg-transactional-tests": "^1.0.5",
54
54
  "rimraf": "^3.0.2",
55
55
  "tslib": "^2.4.0",
56
56
  "typescript": "^4.7.4"
@@ -2,7 +2,7 @@ import { ColumnType } from './columnType';
2
2
  import { Operators } from '../columnsOperators';
3
3
  import {
4
4
  adapter,
5
- AssertEqual,
5
+ assertType,
6
6
  db,
7
7
  expectSql,
8
8
  User,
@@ -87,8 +87,7 @@ describe('column base', () => {
87
87
  const fn = (input: number) => input.toString();
88
88
  const withEncode = column.encode(fn);
89
89
  expect(withEncode.encodeFn).toBe(fn);
90
- const eq: AssertEqual<typeof withEncode.inputType, number> = true;
91
- expect(eq).toBeTruthy();
90
+ assertType<typeof withEncode.inputType, number>();
92
91
  });
93
92
  });
94
93
 
@@ -98,8 +97,7 @@ describe('column base', () => {
98
97
  const fn = () => 123;
99
98
  const withEncode = column.parse(fn);
100
99
  expect(withEncode.parseFn).toBe(fn);
101
- const eq: AssertEqual<typeof withEncode.type, number> = true;
102
- expect(eq).toBeTruthy();
100
+ assertType<typeof withEncode.type, number>();
103
101
  });
104
102
 
105
103
  describe('parsing columns', () => {
@@ -1,4 +1,4 @@
1
- import { AssertEqual, db } from '../test-utils';
1
+ import { assertType, db } from '../test-utils';
2
2
  import { raw } from '../common';
3
3
  import { columnTypes } from './columnTypes';
4
4
  import { TimeInterval } from './dateTime';
@@ -10,8 +10,7 @@ describe('column types', () => {
10
10
  const result = await db.get(raw(columnTypes.smallint(), '1::smallint'));
11
11
  expect(result).toBe(1);
12
12
 
13
- const eq: AssertEqual<typeof result, number> = true;
14
- expect(eq).toBe(true);
13
+ assertType<typeof result, number>();
15
14
  });
16
15
  });
17
16
 
@@ -20,8 +19,7 @@ describe('column types', () => {
20
19
  const result = await db.get(raw(columnTypes.integer(), '1::integer'));
21
20
  expect(result).toBe(1);
22
21
 
23
- const eq: AssertEqual<typeof result, number> = true;
24
- expect(eq).toBe(true);
22
+ assertType<typeof result, number>();
25
23
  });
26
24
  });
27
25
 
@@ -30,8 +28,7 @@ describe('column types', () => {
30
28
  const result = await db.get(raw(columnTypes.bigint(), '1::bigint'));
31
29
  expect(result).toBe('1');
32
30
 
33
- const eq: AssertEqual<typeof result, string> = true;
34
- expect(eq).toBe(true);
31
+ assertType<typeof result, string>();
35
32
  });
36
33
  });
37
34
 
@@ -40,8 +37,7 @@ describe('column types', () => {
40
37
  const result = await db.get(raw(columnTypes.numeric(), '1::numeric'));
41
38
  expect(result).toBe('1');
42
39
 
43
- const eq: AssertEqual<typeof result, string> = true;
44
- expect(eq).toBe(true);
40
+ assertType<typeof result, string>();
45
41
  });
46
42
  });
47
43
 
@@ -50,8 +46,7 @@ describe('column types', () => {
50
46
  const result = await db.get(raw(columnTypes.decimal(), '1::decimal'));
51
47
  expect(result).toBe('1');
52
48
 
53
- const eq: AssertEqual<typeof result, string> = true;
54
- expect(eq).toBe(true);
49
+ assertType<typeof result, string>();
55
50
  });
56
51
  });
57
52
 
@@ -60,8 +55,7 @@ describe('column types', () => {
60
55
  const result = await db.get(raw(columnTypes.real(), '1::real'));
61
56
  expect(result).toBe(1);
62
57
 
63
- const eq: AssertEqual<typeof result, number> = true;
64
- expect(eq).toBe(true);
58
+ assertType<typeof result, number>();
65
59
  });
66
60
  });
67
61
 
@@ -72,8 +66,7 @@ describe('column types', () => {
72
66
  );
73
67
  expect(result).toBe(1);
74
68
 
75
- const eq: AssertEqual<typeof result, number> = true;
76
- expect(eq).toBe(true);
69
+ assertType<typeof result, number>();
77
70
  });
78
71
  });
79
72
 
@@ -84,8 +77,7 @@ describe('column types', () => {
84
77
  );
85
78
  expect(result).toBe(1);
86
79
 
87
- const eq: AssertEqual<typeof result, number> = true;
88
- expect(eq).toBe(true);
80
+ assertType<typeof result, number>();
89
81
  });
90
82
  });
91
83
 
@@ -94,8 +86,7 @@ describe('column types', () => {
94
86
  const result = await db.get(raw(columnTypes.serial(), '1::integer'));
95
87
  expect(result).toBe(1);
96
88
 
97
- const eq: AssertEqual<typeof result, number> = true;
98
- expect(eq).toBe(true);
89
+ assertType<typeof result, number>();
99
90
  });
100
91
  });
101
92
 
@@ -104,8 +95,7 @@ describe('column types', () => {
104
95
  const result = await db.get(raw(columnTypes.bigSerial(), '1::bigint'));
105
96
  expect(result).toBe('1');
106
97
 
107
- const eq: AssertEqual<typeof result, string> = true;
108
- expect(eq).toBe(true);
98
+ assertType<typeof result, string>();
109
99
  });
110
100
  });
111
101
  });
@@ -118,8 +108,7 @@ describe('column types', () => {
118
108
  );
119
109
  expect(result).toBe('text');
120
110
 
121
- const eq: AssertEqual<typeof result, string> = true;
122
- expect(eq).toBe(true);
111
+ assertType<typeof result, string>();
123
112
  });
124
113
  });
125
114
 
@@ -128,8 +117,7 @@ describe('column types', () => {
128
117
  const result = await db.get(raw(columnTypes.char(), `'text'::char(4)`));
129
118
  expect(result).toBe('text');
130
119
 
131
- const eq: AssertEqual<typeof result, string> = true;
132
- expect(eq).toBe(true);
120
+ assertType<typeof result, string>();
133
121
  });
134
122
  });
135
123
 
@@ -138,8 +126,7 @@ describe('column types', () => {
138
126
  const result = await db.get(raw(columnTypes.text(), `'text'::text`));
139
127
  expect(result).toBe('text');
140
128
 
141
- const eq: AssertEqual<typeof result, string> = true;
142
- expect(eq).toBe(true);
129
+ assertType<typeof result, string>();
143
130
  });
144
131
  });
145
132
 
@@ -148,8 +135,7 @@ describe('column types', () => {
148
135
  const result = await db.get(raw(columnTypes.string(), `'text'::text`));
149
136
  expect(result).toBe('text');
150
137
 
151
- const eq: AssertEqual<typeof result, string> = true;
152
- expect(eq).toBe(true);
138
+ assertType<typeof result, string>();
153
139
  });
154
140
  });
155
141
  });
@@ -161,8 +147,7 @@ describe('column types', () => {
161
147
  expect(result instanceof Buffer).toBe(true);
162
148
  expect(result.toString()).toBe('text');
163
149
 
164
- const eq: AssertEqual<typeof result, Buffer> = true;
165
- expect(eq).toBe(true);
150
+ assertType<typeof result, Buffer>();
166
151
  });
167
152
  });
168
153
  });
@@ -175,8 +160,7 @@ describe('column types', () => {
175
160
  );
176
161
  expect(result).toBe('1999-01-08');
177
162
 
178
- const eq: AssertEqual<typeof result, string> = true;
179
- expect(eq).toBe(true);
163
+ assertType<typeof result, string>();
180
164
  });
181
165
  });
182
166
 
@@ -187,8 +171,7 @@ describe('column types', () => {
187
171
  );
188
172
  expect(result).toBe('1999-01-08 04:05:06');
189
173
 
190
- const eq: AssertEqual<typeof result, string> = true;
191
- expect(eq).toBe(true);
174
+ assertType<typeof result, string>();
192
175
  });
193
176
  });
194
177
 
@@ -202,8 +185,7 @@ describe('column types', () => {
202
185
  );
203
186
  expect(result).toBe('1999-01-08 04:05:06');
204
187
 
205
- const eq: AssertEqual<typeof result, string> = true;
206
- expect(eq).toBe(true);
188
+ assertType<typeof result, string>();
207
189
  });
208
190
  });
209
191
 
@@ -212,8 +194,7 @@ describe('column types', () => {
212
194
  const result = await db.get(raw(columnTypes.time(), `'12:00'::time`));
213
195
  expect(result).toBe('12:00:00');
214
196
 
215
- const eq: AssertEqual<typeof result, string> = true;
216
- expect(eq).toBe(true);
197
+ assertType<typeof result, string>();
217
198
  });
218
199
  });
219
200
 
@@ -227,8 +208,7 @@ describe('column types', () => {
227
208
  );
228
209
  expect(result).toBe('12:00:00+00');
229
210
 
230
- const eq: AssertEqual<typeof result, string> = true;
231
- expect(eq).toBe(true);
211
+ assertType<typeof result, string>();
232
212
  });
233
213
  });
234
214
 
@@ -249,8 +229,7 @@ describe('column types', () => {
249
229
  seconds: 6,
250
230
  });
251
231
 
252
- const eq: AssertEqual<typeof result, TimeInterval> = true;
253
- expect(eq).toBe(true);
232
+ assertType<typeof result, TimeInterval>();
254
233
  });
255
234
  });
256
235
  });
@@ -261,8 +240,7 @@ describe('column types', () => {
261
240
  const result = await db.get(raw(columnTypes.boolean(), `true`));
262
241
  expect(result).toBe(true);
263
242
 
264
- const eq: AssertEqual<typeof result, boolean> = true;
265
- expect(eq).toBe(true);
243
+ assertType<typeof result, boolean>();
266
244
  });
267
245
  });
268
246
  });
@@ -289,8 +267,7 @@ describe('column types', () => {
289
267
  );
290
268
  expect(result).toBe('happy');
291
269
 
292
- const eq: AssertEqual<typeof result, MoodUnion> = true;
293
- expect(eq).toBe(true);
270
+ assertType<typeof result, MoodUnion>();
294
271
  });
295
272
  });
296
273
  });
@@ -303,8 +280,7 @@ describe('column types', () => {
303
280
  );
304
281
  expect(result).toBe('(1,2)');
305
282
 
306
- const eq: AssertEqual<typeof result, string> = true;
307
- expect(eq).toBe(true);
283
+ assertType<typeof result, string>();
308
284
  });
309
285
  });
310
286
 
@@ -315,8 +291,7 @@ describe('column types', () => {
315
291
  );
316
292
  expect(result).toBe('{1,2,3}');
317
293
 
318
- const eq: AssertEqual<typeof result, string> = true;
319
- expect(eq).toBe(true);
294
+ assertType<typeof result, string>();
320
295
  });
321
296
  });
322
297
 
@@ -327,8 +302,7 @@ describe('column types', () => {
327
302
  );
328
303
  expect(result).toBe('[(1,2),(3,4)]');
329
304
 
330
- const eq: AssertEqual<typeof result, string> = true;
331
- expect(eq).toBe(true);
305
+ assertType<typeof result, string>();
332
306
  });
333
307
  });
334
308
 
@@ -339,8 +313,7 @@ describe('column types', () => {
339
313
  );
340
314
  expect(result).toBe('(3,4),(1,2)');
341
315
 
342
- const eq: AssertEqual<typeof result, string> = true;
343
- expect(eq).toBe(true);
316
+ assertType<typeof result, string>();
344
317
  });
345
318
  });
346
319
 
@@ -351,8 +324,7 @@ describe('column types', () => {
351
324
  );
352
325
  expect(result).toBe('((1,2),(3,4))');
353
326
 
354
- const eq: AssertEqual<typeof result, string> = true;
355
- expect(eq).toBe(true);
327
+ assertType<typeof result, string>();
356
328
  });
357
329
  });
358
330
 
@@ -363,8 +335,7 @@ describe('column types', () => {
363
335
  );
364
336
  expect(result).toBe('((1,2),(3,4))');
365
337
 
366
- const eq: AssertEqual<typeof result, string> = true;
367
- expect(eq).toBe(true);
338
+ assertType<typeof result, string>();
368
339
  });
369
340
  });
370
341
 
@@ -375,8 +346,7 @@ describe('column types', () => {
375
346
  );
376
347
  expect(result).toBe('<(1,2),3>');
377
348
 
378
- const eq: AssertEqual<typeof result, string> = true;
379
- expect(eq).toBe(true);
349
+ assertType<typeof result, string>();
380
350
  });
381
351
  });
382
352
  });
@@ -389,8 +359,7 @@ describe('column types', () => {
389
359
  );
390
360
  expect(result).toBe('192.168.100.128/25');
391
361
 
392
- const eq: AssertEqual<typeof result, string> = true;
393
- expect(eq).toBe(true);
362
+ assertType<typeof result, string>();
394
363
  });
395
364
  });
396
365
 
@@ -401,8 +370,7 @@ describe('column types', () => {
401
370
  );
402
371
  expect(result).toBe('192.168.100.128/25');
403
372
 
404
- const eq: AssertEqual<typeof result, string> = true;
405
- expect(eq).toBe(true);
373
+ assertType<typeof result, string>();
406
374
  });
407
375
  });
408
376
 
@@ -413,8 +381,7 @@ describe('column types', () => {
413
381
  );
414
382
  expect(result).toBe('08:00:2b:01:02:03');
415
383
 
416
- const eq: AssertEqual<typeof result, string> = true;
417
- expect(eq).toBe(true);
384
+ assertType<typeof result, string>();
418
385
  });
419
386
  });
420
387
 
@@ -425,8 +392,7 @@ describe('column types', () => {
425
392
  );
426
393
  expect(result).toBe('08:00:2b:ff:fe:01:02:03');
427
394
 
428
- const eq: AssertEqual<typeof result, string> = true;
429
- expect(eq).toBe(true);
395
+ assertType<typeof result, string>();
430
396
  });
431
397
  });
432
398
  });
@@ -437,8 +403,7 @@ describe('column types', () => {
437
403
  const result = await db.get(raw(columnTypes.bit(3), `B'101'`));
438
404
  expect(result).toBe('101');
439
405
 
440
- const eq: AssertEqual<typeof result, string> = true;
441
- expect(eq).toBe(true);
406
+ assertType<typeof result, string>();
442
407
  });
443
408
  });
444
409
 
@@ -449,8 +414,7 @@ describe('column types', () => {
449
414
  );
450
415
  expect(result).toBe('10101');
451
416
 
452
- const eq: AssertEqual<typeof result, string> = true;
453
- expect(eq).toBe(true);
417
+ assertType<typeof result, string>();
454
418
  });
455
419
  });
456
420
  });
@@ -468,8 +432,7 @@ describe('column types', () => {
468
432
  `'a' 'and' 'ate' 'cat' 'fat' 'mat' 'on' 'rat' 'sat'`,
469
433
  );
470
434
 
471
- const eq: AssertEqual<typeof result, string> = true;
472
- expect(eq).toBe(true);
435
+ assertType<typeof result, string>();
473
436
  });
474
437
  });
475
438
 
@@ -480,8 +443,7 @@ describe('column types', () => {
480
443
  );
481
444
  expect(result).toBe(`'fat' & 'rat'`);
482
445
 
483
- const eq: AssertEqual<typeof result, string> = true;
484
- expect(eq).toBe(true);
446
+ assertType<typeof result, string>();
485
447
  });
486
448
  });
487
449
  });
@@ -497,8 +459,7 @@ describe('column types', () => {
497
459
  );
498
460
  expect(result).toBe(`a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11`);
499
461
 
500
- const eq: AssertEqual<typeof result, string> = true;
501
- expect(eq).toBe(true);
462
+ assertType<typeof result, string>();
502
463
  });
503
464
  });
504
465
  });
@@ -517,8 +478,7 @@ describe('column types', () => {
517
478
  [4, 5, 6],
518
479
  ]);
519
480
 
520
- const eq: AssertEqual<typeof result, number[][]> = true;
521
- expect(eq).toBe(true);
481
+ assertType<typeof result, number[][]>();
522
482
  });
523
483
 
524
484
  it('should output nested array of strings', async () => {
@@ -533,8 +493,7 @@ describe('column types', () => {
533
493
  ['c', 'd'],
534
494
  ]);
535
495
 
536
- const eq: AssertEqual<typeof result, string[][]> = true;
537
- expect(eq).toBe(true);
496
+ assertType<typeof result, string[][]>();
538
497
  });
539
498
 
540
499
  it('should output nested array of booleans', async () => {
@@ -546,8 +505,7 @@ describe('column types', () => {
546
505
  );
547
506
  expect(result).toEqual([[true], [false]]);
548
507
 
549
- const eq: AssertEqual<typeof result, boolean[][]> = true;
550
- expect(eq).toBe(true);
508
+ assertType<typeof result, boolean[][]>();
551
509
  });
552
510
  });
553
511
  });
@@ -560,8 +518,7 @@ describe('column types', () => {
560
518
  );
561
519
  expect(result).toBe(1234567890.42);
562
520
 
563
- const eq: AssertEqual<typeof result, number> = true;
564
- expect(eq).toBe(true);
521
+ assertType<typeof result, number>();
565
522
  });
566
523
  });
567
524
  });
package/src/db.test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  adapter,
3
- AssertEqual,
3
+ assertType,
4
4
  db,
5
5
  expectSql,
6
6
  User,
@@ -38,8 +38,7 @@ describe('db', () => {
38
38
  const result = await table.take().get('createdAt');
39
39
  expect(typeof result).toBe('string');
40
40
 
41
- const eq: AssertEqual<typeof result, string> = true;
42
- expect(eq).toBe(true);
41
+ assertType<typeof result, string>();
43
42
  });
44
43
 
45
44
  it('should return date as Date when overridden', async () => {
@@ -60,8 +59,7 @@ describe('db', () => {
60
59
  const result = await table.take().get('createdAt');
61
60
  expect(result instanceof Date).toBe(true);
62
61
 
63
- const eq: AssertEqual<typeof result, Date> = true;
64
- expect(eq).toBe(true);
62
+ assertType<typeof result, Date>();
65
63
  });
66
64
  });
67
65
  });