@balena/abstract-sql-compiler 10.2.4-build-update-dev-deps-703263fa73aff2253d1a931a5946a027d20c9ff6-1 → 10.2.4-build-tests-ts-beb2503119ff2e479e1da25051d33a021129a9d7-1
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/.versionbot/CHANGELOG.yml +9 -1
- package/CHANGELOG.md +1 -0
- package/package.json +2 -2
- package/test/odata/expand.js +79 -78
- package/test/odata/filterby.js +36 -36
- package/test/odata/orderby.js +8 -8
- package/test/odata/paging.js +3 -3
- package/test/odata/resource_parsing.js +40 -38
- package/test/odata/select.js +9 -9
- package/test/odata/stress.js +6 -5
- package/test/odata/test.ts +292 -0
- package/test/odata/test.js +0 -138
@@ -22,7 +22,7 @@ const teamFieldsStr = teamFields.join(', ');
|
|
22
22
|
test('/pilot', (result, sqlEquals) => {
|
23
23
|
it('should select from pilot', () => {
|
24
24
|
sqlEquals(
|
25
|
-
result
|
25
|
+
result,
|
26
26
|
`\
|
27
27
|
SELECT ${pilotFieldsStr}
|
28
28
|
FROM "pilot"`,
|
@@ -33,7 +33,7 @@ FROM "pilot"`,
|
|
33
33
|
test('/pilot(1)', 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
34
34
|
it('should select from pilot with id', () => {
|
35
35
|
sqlEquals(
|
36
|
-
result
|
36
|
+
result,
|
37
37
|
`\
|
38
38
|
SELECT ${pilotFieldsStr}
|
39
39
|
FROM "pilot"
|
@@ -45,7 +45,7 @@ WHERE ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)`,
|
|
45
45
|
test("/pilot('TextKey')", 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
46
46
|
it('should select from pilot with id', () => {
|
47
47
|
sqlEquals(
|
48
|
-
result
|
48
|
+
result,
|
49
49
|
`\
|
50
50
|
SELECT ${pilotFieldsStr}
|
51
51
|
FROM "pilot"
|
@@ -57,7 +57,7 @@ WHERE ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)`,
|
|
57
57
|
test('/pilot(1)/licence', 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
58
58
|
it('should select from the licence of pilot with id', () => {
|
59
59
|
sqlEquals(
|
60
|
-
result
|
60
|
+
result,
|
61
61
|
`\
|
62
62
|
SELECT ${aliasLicenceFieldsStr}
|
63
63
|
FROM "pilot",
|
@@ -71,7 +71,7 @@ AND ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)`,
|
|
71
71
|
test('/licence(1)/is_of__pilot', 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
72
72
|
it('should select from the pilots of licence with id', () => {
|
73
73
|
sqlEquals(
|
74
|
-
result
|
74
|
+
result,
|
75
75
|
`\
|
76
76
|
SELECT ${aliasPilotLicenceFieldsStr}
|
77
77
|
FROM "licence",
|
@@ -89,7 +89,7 @@ test(
|
|
89
89
|
(result, sqlEquals) => {
|
90
90
|
it('should select from the plane of pilot with id', () => {
|
91
91
|
sqlEquals(
|
92
|
-
result
|
92
|
+
result,
|
93
93
|
`\
|
94
94
|
SELECT ${aliasPlaneFieldsStr}
|
95
95
|
FROM "pilot",
|
@@ -110,7 +110,7 @@ test(
|
|
110
110
|
(result, sqlEquals) => {
|
111
111
|
it('should select from the pilots of plane with id', () => {
|
112
112
|
sqlEquals(
|
113
|
-
result
|
113
|
+
result,
|
114
114
|
`\
|
115
115
|
SELECT ${aliasPilotFields}
|
116
116
|
FROM "plane",
|
@@ -127,7 +127,7 @@ AND ("plane"."id") IS NOT NULL AND ("plane"."id") = (?)`,
|
|
127
127
|
test('/pilot(1)', 'DELETE', [['Bind', 0]], (result, sqlEquals) => {
|
128
128
|
it('should delete the pilot with id 1', () => {
|
129
129
|
sqlEquals(
|
130
|
-
result
|
130
|
+
result,
|
131
131
|
`\
|
132
132
|
DELETE FROM "pilot"
|
133
133
|
WHERE ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)`,
|
@@ -195,7 +195,7 @@ test(
|
|
195
195
|
(result, sqlEquals) => {
|
196
196
|
it('should insert/update the pilot with id 1', () => {
|
197
197
|
sqlEquals(
|
198
|
-
result
|
198
|
+
result,
|
199
199
|
`\
|
200
200
|
INSERT INTO "pilot" ("name")
|
201
201
|
VALUES (?)`,
|
@@ -206,7 +206,7 @@ VALUES (?)`,
|
|
206
206
|
test('/pilot', 'POST', (result, sqlEquals) => {
|
207
207
|
it('should insert a pilot with default values', () => {
|
208
208
|
sqlEquals(
|
209
|
-
result
|
209
|
+
result,
|
210
210
|
`\
|
211
211
|
INSERT INTO "pilot" DEFAULT VALUES`,
|
212
212
|
);
|
@@ -214,14 +214,15 @@ INSERT INTO "pilot" DEFAULT VALUES`,
|
|
214
214
|
});
|
215
215
|
|
216
216
|
(function () {
|
217
|
-
|
217
|
+
// prettier-ignore
|
218
|
+
const bindings = /** @type {const} */ ([
|
218
219
|
['Bind', ['pilot', 'is_experienced']],
|
219
220
|
['Bind', 0],
|
220
|
-
];
|
221
|
+
]);
|
221
222
|
const testFunc = (result, sqlEquals) => {
|
222
223
|
it('should update the pilot with id 1', () => {
|
223
224
|
sqlEquals(
|
224
|
-
result
|
225
|
+
result,
|
225
226
|
`\
|
226
227
|
UPDATE "pilot"
|
227
228
|
SET "is experienced" = ?
|
@@ -240,7 +241,7 @@ test(
|
|
240
241
|
(result, sqlEquals) => {
|
241
242
|
it('should delete the pilot with id 1', () => {
|
242
243
|
sqlEquals(
|
243
|
-
result
|
244
|
+
result,
|
244
245
|
`\
|
245
246
|
DELETE FROM "pilot-can fly-plane"
|
246
247
|
WHERE ("pilot-can fly-plane"."id") IS NOT NULL AND ("pilot-can fly-plane"."id") = (?)`,
|
@@ -305,7 +306,7 @@ test(
|
|
305
306
|
(result, sqlEquals) => {
|
306
307
|
it('should insert/update the pilot-can fly-plane with id 1', () => {
|
307
308
|
sqlEquals(
|
308
|
-
result
|
309
|
+
result,
|
309
310
|
`\
|
310
311
|
INSERT INTO "pilot-can fly-plane" ("pilot", "can fly-plane")
|
311
312
|
VALUES (?, ?)`,
|
@@ -316,7 +317,7 @@ VALUES (?, ?)`,
|
|
316
317
|
test('/pilot__can_fly__plane', 'POST', (result, sqlEquals) => {
|
317
318
|
it('should insert a "pilot-can fly-plane" with default values', () => {
|
318
319
|
sqlEquals(
|
319
|
-
result
|
320
|
+
result,
|
320
321
|
`\
|
321
322
|
INSERT INTO "pilot-can fly-plane" DEFAULT VALUES`,
|
322
323
|
);
|
@@ -324,14 +325,15 @@ INSERT INTO "pilot-can fly-plane" DEFAULT VALUES`,
|
|
324
325
|
});
|
325
326
|
|
326
327
|
(function () {
|
327
|
-
|
328
|
+
// prettier-ignore
|
329
|
+
const bindings = /** @type {const} */ ([
|
328
330
|
['Bind', ['pilot-can fly-plane', 'pilot']],
|
329
331
|
['Bind', 0],
|
330
|
-
];
|
332
|
+
]);
|
331
333
|
const testFunc = (result, sqlEquals) => {
|
332
334
|
it('should update the pilot with id 1', () => {
|
333
335
|
sqlEquals(
|
334
|
-
result
|
336
|
+
result,
|
335
337
|
`\
|
336
338
|
UPDATE "pilot-can fly-plane"
|
337
339
|
SET "pilot" = ?
|
@@ -346,7 +348,7 @@ WHERE ("pilot-can fly-plane"."id") IS NOT NULL AND ("pilot-can fly-plane"."id")
|
|
346
348
|
test('/pilot(1)/$links/licence', 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
347
349
|
it('should select the list of licence ids, for generating the links', () => {
|
348
350
|
sqlEquals(
|
349
|
-
result
|
351
|
+
result,
|
350
352
|
`\
|
351
353
|
SELECT "pilot"."licence" AS "licence"
|
352
354
|
FROM "pilot"
|
@@ -362,7 +364,7 @@ test(
|
|
362
364
|
(result, sqlEquals) => {
|
363
365
|
it('should select the list of plane ids, for generating the links', () => {
|
364
366
|
sqlEquals(
|
365
|
-
result
|
367
|
+
result,
|
366
368
|
`\
|
367
369
|
SELECT "pilot.pilot-can fly-plane"."can fly-plane" AS "plane"
|
368
370
|
FROM "pilot",
|
@@ -374,18 +376,18 @@ AND ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)`,
|
|
374
376
|
},
|
375
377
|
);
|
376
378
|
|
377
|
-
test.
|
379
|
+
test.fail('/pilot(1)/favourite_colour/red', () => {
|
378
380
|
it("should select the red component of the pilot's favourite colour");
|
379
381
|
});
|
380
382
|
|
381
|
-
test.
|
383
|
+
test.fail('/method(1)/child?foo=bar', () => {
|
382
384
|
it('should do something..');
|
383
385
|
});
|
384
386
|
|
385
387
|
test("/team('purple')", 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
386
388
|
it('should select the team with the "favourite colour" id of "purple"', () => {
|
387
389
|
sqlEquals(
|
388
|
-
result
|
390
|
+
result,
|
389
391
|
`\
|
390
392
|
SELECT ${teamFieldsStr}
|
391
393
|
FROM "team"
|
@@ -402,7 +404,7 @@ test(
|
|
402
404
|
(result, sqlEquals) => {
|
403
405
|
it('should insert a team', () => {
|
404
406
|
sqlEquals(
|
405
|
-
result
|
407
|
+
result,
|
406
408
|
`\
|
407
409
|
INSERT INTO "team" ("favourite colour")
|
408
410
|
VALUES (?)`,
|
@@ -411,7 +413,7 @@ VALUES (?)`,
|
|
411
413
|
},
|
412
414
|
);
|
413
415
|
|
414
|
-
test('/pilot/$count/$count', (result) => {
|
416
|
+
test.fail('/pilot/$count/$count', (result) => {
|
415
417
|
it('should fail because it is invalid', () => {
|
416
418
|
expect(result).to.be.instanceOf(ODataParser.SyntaxError);
|
417
419
|
});
|
@@ -420,7 +422,7 @@ test('/pilot/$count/$count', (result) => {
|
|
420
422
|
test('/pilot/$count', (result, sqlEquals) => {
|
421
423
|
it('should select count(*) from pilot', () => {
|
422
424
|
sqlEquals(
|
423
|
-
result
|
425
|
+
result,
|
424
426
|
`\
|
425
427
|
SELECT COUNT(*) AS "$count"
|
426
428
|
FROM "pilot"`,
|
@@ -428,13 +430,13 @@ FROM "pilot"`,
|
|
428
430
|
});
|
429
431
|
});
|
430
432
|
|
431
|
-
test('/pilot(5)/$count', (result) => {
|
433
|
+
test.fail('/pilot(5)/$count', (result) => {
|
432
434
|
it('should fail because it is invalid', () => {
|
433
435
|
expect(result).to.be.instanceOf(ODataParser.SyntaxError);
|
434
436
|
});
|
435
437
|
});
|
436
438
|
|
437
|
-
test('/pilot?$filter=id eq 5/$count', (result) => {
|
439
|
+
test.fail('/pilot?$filter=id eq 5/$count', (result) => {
|
438
440
|
it('should fail because it is invalid', () => {
|
439
441
|
expect(result).to.be.instanceOf(ODataParser.SyntaxError);
|
440
442
|
});
|
@@ -447,7 +449,7 @@ test(
|
|
447
449
|
(result, sqlEquals) => {
|
448
450
|
it('should select count(*) from pilot where pilot/id > 5 ', () => {
|
449
451
|
sqlEquals(
|
450
|
-
result
|
452
|
+
result,
|
451
453
|
`\
|
452
454
|
SELECT COUNT(*) AS "$count"
|
453
455
|
FROM "pilot"
|
@@ -467,7 +469,7 @@ test(
|
|
467
469
|
(result, sqlEquals) => {
|
468
470
|
it('should select count(*) from pilot where id in (5,10)', () => {
|
469
471
|
sqlEquals(
|
470
|
-
result
|
472
|
+
result,
|
471
473
|
`\
|
472
474
|
SELECT COUNT(*) AS "$count"
|
473
475
|
FROM "pilot"
|
@@ -485,7 +487,7 @@ test(
|
|
485
487
|
(result, sqlEquals) => {
|
486
488
|
it('should select count(*) from pilot where id in (5,10)', () => {
|
487
489
|
sqlEquals(
|
488
|
-
result
|
490
|
+
result,
|
489
491
|
`\
|
490
492
|
SELECT COUNT(*) AS "$count"
|
491
493
|
FROM "pilot"
|
@@ -499,7 +501,7 @@ OR "pilot"."id" IS NULL)`,
|
|
499
501
|
test('/pilot(5)/licence/$count', 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
500
502
|
it('should select count(*) the licence from pilot where pilot/id', () => {
|
501
503
|
sqlEquals(
|
502
|
-
result
|
504
|
+
result,
|
503
505
|
`\
|
504
506
|
SELECT COUNT(*) AS "$count"
|
505
507
|
FROM "pilot",
|
@@ -513,7 +515,7 @@ AND ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)`,
|
|
513
515
|
test('/pilot/$count?$orderby=id asc', (result, sqlEquals) => {
|
514
516
|
it('should select count(*) from pilot and ignore orderby', () => {
|
515
517
|
sqlEquals(
|
516
|
-
result
|
518
|
+
result,
|
517
519
|
`\
|
518
520
|
SELECT COUNT(*) AS "$count"
|
519
521
|
FROM "pilot"`,
|
@@ -524,7 +526,7 @@ FROM "pilot"`,
|
|
524
526
|
test('/pilot/$count?$skip=5', (result, sqlEquals) => {
|
525
527
|
it('should select count(*) from pilot and ignore skip', () => {
|
526
528
|
sqlEquals(
|
527
|
-
result
|
529
|
+
result,
|
528
530
|
`\
|
529
531
|
SELECT COUNT(*) AS "$count"
|
530
532
|
FROM "pilot"`,
|
@@ -535,7 +537,7 @@ FROM "pilot"`,
|
|
535
537
|
test('/pilot/$count?$top=5', (result, sqlEquals) => {
|
536
538
|
it('should select count(*) from pilot and ignore top', () => {
|
537
539
|
sqlEquals(
|
538
|
-
result
|
540
|
+
result,
|
539
541
|
`\
|
540
542
|
SELECT COUNT(*) AS "$count"
|
541
543
|
FROM "pilot"`,
|
@@ -546,7 +548,7 @@ FROM "pilot"`,
|
|
546
548
|
test('/pilot/$count?$top=5&$skip=5', (result, sqlEquals) => {
|
547
549
|
it('should select count(*) from pilot and ignore top and skip', () => {
|
548
550
|
sqlEquals(
|
549
|
-
result
|
551
|
+
result,
|
550
552
|
`\
|
551
553
|
SELECT COUNT(*) AS "$count"
|
552
554
|
FROM "pilot"`,
|
@@ -557,7 +559,7 @@ FROM "pilot"`,
|
|
557
559
|
test('/pilot/$count?$select=id', (result, sqlEquals) => {
|
558
560
|
it('should select count(*) from pilot and ignore select', () => {
|
559
561
|
sqlEquals(
|
560
|
-
result
|
562
|
+
result,
|
561
563
|
`\
|
562
564
|
SELECT COUNT(*) AS "$count"
|
563
565
|
FROM "pilot"`,
|
package/test/odata/select.js
CHANGED
@@ -5,7 +5,7 @@ const pilotFieldsStr = pilotFields.join(', ');
|
|
5
5
|
test('/pilot?$select=name', (result, sqlEquals) => {
|
6
6
|
it('should select name from pilot', () => {
|
7
7
|
sqlEquals(
|
8
|
-
result
|
8
|
+
result,
|
9
9
|
`\
|
10
10
|
SELECT "pilot"."name"
|
11
11
|
FROM "pilot"`,
|
@@ -16,7 +16,7 @@ FROM "pilot"`,
|
|
16
16
|
test('/pilot?$select=favourite_colour', (result, sqlEquals) => {
|
17
17
|
it('should select favourite_colour from pilot', () => {
|
18
18
|
sqlEquals(
|
19
|
-
result
|
19
|
+
result,
|
20
20
|
`\
|
21
21
|
SELECT "pilot"."favourite colour" AS "favourite_colour"
|
22
22
|
FROM "pilot"`,
|
@@ -31,7 +31,7 @@ test(
|
|
31
31
|
(result, sqlEquals) => {
|
32
32
|
it('should select from pilot with id', () => {
|
33
33
|
sqlEquals(
|
34
|
-
result
|
34
|
+
result,
|
35
35
|
`\
|
36
36
|
SELECT "pilot"."favourite colour" AS "favourite_colour"
|
37
37
|
FROM "pilot"
|
@@ -48,7 +48,7 @@ test(
|
|
48
48
|
(result, sqlEquals) => {
|
49
49
|
it('should select favourite colour from pilot "TextKey"', () => {
|
50
50
|
sqlEquals(
|
51
|
-
result
|
51
|
+
result,
|
52
52
|
`\
|
53
53
|
SELECT "pilot"."favourite colour" AS "favourite_colour"
|
54
54
|
FROM "pilot"
|
@@ -61,7 +61,7 @@ WHERE ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)`,
|
|
61
61
|
test('/pilot?$select=trained__pilot/name', (result, sqlEquals) => {
|
62
62
|
it('should select name from pilot', () => {
|
63
63
|
sqlEquals(
|
64
|
-
result
|
64
|
+
result,
|
65
65
|
`\
|
66
66
|
SELECT "pilot.trained-pilot"."name"
|
67
67
|
FROM "pilot"
|
@@ -73,7 +73,7 @@ LEFT JOIN "pilot" AS "pilot.trained-pilot" ON "pilot"."id" = "pilot.trained-pilo
|
|
73
73
|
test('/pilot?$select=trained__pilot/name,age', (result, sqlEquals) => {
|
74
74
|
it('should select name, age from pilot', () => {
|
75
75
|
sqlEquals(
|
76
|
-
result
|
76
|
+
result,
|
77
77
|
`\
|
78
78
|
SELECT "pilot.trained-pilot"."name", "pilot"."age"
|
79
79
|
FROM "pilot"
|
@@ -85,7 +85,7 @@ LEFT JOIN "pilot" AS "pilot.trained-pilot" ON "pilot"."id" = "pilot.trained-pilo
|
|
85
85
|
test('/pilot?$select=*', (result, sqlEquals) => {
|
86
86
|
it('should select * from pilot', () => {
|
87
87
|
sqlEquals(
|
88
|
-
result
|
88
|
+
result,
|
89
89
|
`\
|
90
90
|
SELECT ${pilotFieldsStr}
|
91
91
|
FROM "pilot"`,
|
@@ -96,7 +96,7 @@ FROM "pilot"`,
|
|
96
96
|
test('/pilot?$select=licence/id', (result, sqlEquals) => {
|
97
97
|
it('should select licence/id for pilots', () => {
|
98
98
|
sqlEquals(
|
99
|
-
result
|
99
|
+
result,
|
100
100
|
`\
|
101
101
|
SELECT "pilot.licence"."id"
|
102
102
|
FROM "pilot"
|
@@ -108,7 +108,7 @@ LEFT JOIN "licence" AS "pilot.licence" ON "pilot"."licence" = "pilot.licence"."i
|
|
108
108
|
test('/pilot?$select=can_fly__plane/plane/id', (result, sqlEquals) => {
|
109
109
|
it('should select can_fly__plane/plane/id for pilots', () => {
|
110
110
|
sqlEquals(
|
111
|
-
result
|
111
|
+
result,
|
112
112
|
`\
|
113
113
|
SELECT "pilot.pilot-can fly-plane.plane"."id"
|
114
114
|
FROM "pilot"
|
package/test/odata/stress.js
CHANGED
@@ -14,7 +14,8 @@ const filterBindsNandString = _.map(
|
|
14
14
|
() => 'NOT(("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?))',
|
15
15
|
).join('\nAND ');
|
16
16
|
|
17
|
-
|
17
|
+
// prettier-ignore
|
18
|
+
const filterBinds = filterIDs.map((_n, i) => /** @type {const} */ (['Bind', i]));
|
18
19
|
|
19
20
|
let filterString = `id in (${filterIDs.join(', ')})`;
|
20
21
|
test(
|
@@ -24,7 +25,7 @@ test(
|
|
24
25
|
(result, sqlEquals) => {
|
25
26
|
it('should select from pilot with a long IN clause', () => {
|
26
27
|
sqlEquals(
|
27
|
-
result
|
28
|
+
result,
|
28
29
|
`\
|
29
30
|
SELECT ${pilotFieldsStr}
|
30
31
|
FROM "pilot"
|
@@ -44,7 +45,7 @@ test(
|
|
44
45
|
(result, sqlEquals) => {
|
45
46
|
it('should select from pilot with a long NOT IN clause', () => {
|
46
47
|
sqlEquals(
|
47
|
-
result
|
48
|
+
result,
|
48
49
|
`\
|
49
50
|
SELECT ${pilotFieldsStr}
|
50
51
|
FROM "pilot"
|
@@ -64,7 +65,7 @@ test(
|
|
64
65
|
(result, sqlEquals) => {
|
65
66
|
it('should select from pilot with a long IN clause', () => {
|
66
67
|
sqlEquals(
|
67
|
-
result
|
68
|
+
result,
|
68
69
|
`\
|
69
70
|
SELECT ${pilotFieldsStr}
|
70
71
|
FROM "pilot"
|
@@ -82,7 +83,7 @@ test(
|
|
82
83
|
(result, sqlEquals) => {
|
83
84
|
it('should select from pilot with a long NOT IN clause', () => {
|
84
85
|
sqlEquals(
|
85
|
-
result
|
86
|
+
result,
|
86
87
|
`\
|
87
88
|
SELECT ${pilotFieldsStr}
|
88
89
|
FROM "pilot"
|