@balena/abstract-sql-compiler 10.2.4 → 10.2.5-build-tests-ts-c00e9270589111b882d4894fc437dd8b0343ecce-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 +13 -1
- package/CHANGELOG.md +4 -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
package/test/odata/filterby.js
CHANGED
@@ -365,7 +365,7 @@ LEFT JOIN "pilot" AS "pilot.trained-pilot" ON "pilot"."id" = "pilot.trained-pilo
|
|
365
365
|
test(`/pilot?$filter=${odata}`, 'GET', bindings, (result, sqlEquals) => {
|
366
366
|
it('should select from pilot where "' + odata + '"', () => {
|
367
367
|
sqlEquals(
|
368
|
-
result
|
368
|
+
result,
|
369
369
|
`\
|
370
370
|
SELECT ${pilotFieldsStr}
|
371
371
|
FROM ${from}
|
@@ -380,7 +380,7 @@ WHERE ${sql}`,
|
|
380
380
|
(result, sqlEquals) => {
|
381
381
|
it('should select count(*) from pilot where "' + odata + '"', () => {
|
382
382
|
sqlEquals(
|
383
|
-
result
|
383
|
+
result,
|
384
384
|
`\
|
385
385
|
SELECT COUNT(*) AS "$count"
|
386
386
|
FROM ${from}
|
@@ -398,7 +398,7 @@ const methodTest = (...args) => {
|
|
398
398
|
test(`/pilot?$filter=${odata}`, 'GET', bindings, (result, sqlEquals) => {
|
399
399
|
it('should select from pilot where "' + odata + '"', () => {
|
400
400
|
sqlEquals(
|
401
|
-
result
|
401
|
+
result,
|
402
402
|
`\
|
403
403
|
SELECT ${pilotFieldsStr}
|
404
404
|
FROM "pilot"
|
@@ -413,7 +413,7 @@ WHERE ` + sql,
|
|
413
413
|
(result, sqlEquals) => {
|
414
414
|
it('should select count(*) from pilot where "' + odata + '"', () => {
|
415
415
|
sqlEquals(
|
416
|
-
result
|
416
|
+
result,
|
417
417
|
`\
|
418
418
|
SELECT COUNT(*) AS "$count"
|
419
419
|
FROM "pilot"
|
@@ -513,7 +513,7 @@ run(function () {
|
|
513
513
|
(result, sqlEquals) => {
|
514
514
|
it('should select from pilot where "' + odata + '"', () => {
|
515
515
|
sqlEquals(
|
516
|
-
result
|
516
|
+
result,
|
517
517
|
`\
|
518
518
|
SELECT ${pilotFieldsStr}
|
519
519
|
FROM "pilot"
|
@@ -533,7 +533,7 @@ run(function () {
|
|
533
533
|
(result, sqlEquals) => {
|
534
534
|
it('should select from pilot where "' + odata + '"', () => {
|
535
535
|
sqlEquals(
|
536
|
-
result
|
536
|
+
result,
|
537
537
|
`\
|
538
538
|
SELECT ${pilotFieldsStr}
|
539
539
|
FROM "pilot"
|
@@ -554,7 +554,7 @@ run(function () {
|
|
554
554
|
test(`/pilot?$filter=${odata}`, 'GET', bindings, (result, sqlEquals) => {
|
555
555
|
it('should select from pilot where "' + odata + '"', () => {
|
556
556
|
sqlEquals(
|
557
|
-
result
|
557
|
+
result,
|
558
558
|
`\
|
559
559
|
SELECT ${pilotFieldsStr}
|
560
560
|
FROM "pilot"
|
@@ -577,7 +577,7 @@ run(function () {
|
|
577
577
|
'should select from pilot__can_fly__plane where "' + odata + '"',
|
578
578
|
() => {
|
579
579
|
sqlEquals(
|
580
|
-
result
|
580
|
+
result,
|
581
581
|
`\
|
582
582
|
SELECT ${aliasPilotCanFlyPlaneFieldsStr}
|
583
583
|
FROM "pilot",
|
@@ -600,10 +600,10 @@ run(function () {
|
|
600
600
|
10,
|
601
601
|
);
|
602
602
|
const name = 'Peter';
|
603
|
-
const bodyBindings = [['Bind', ['pilot', 'name']]]
|
603
|
+
const bodyBindings = [['Bind', ['pilot', 'name']], ...bindings];
|
604
604
|
const insertTest = (result, sqlEquals) => {
|
605
605
|
sqlEquals(
|
606
|
-
result
|
606
|
+
result,
|
607
607
|
`\
|
608
608
|
INSERT INTO "pilot" ("name")
|
609
609
|
SELECT "$insert"."name"
|
@@ -633,7 +633,7 @@ WHERE "pilot"."id" IN ((
|
|
633
633
|
test(`/pilot?$filter=${odata}`, 'GET', bindings, (result, sqlEquals) => {
|
634
634
|
it(`should select from pilot where '${odata}'`, () => {
|
635
635
|
sqlEquals(
|
636
|
-
result
|
636
|
+
result,
|
637
637
|
`\
|
638
638
|
SELECT ${pilotFieldsStr}
|
639
639
|
FROM "pilot"
|
@@ -652,7 +652,7 @@ WHERE ${sql}`,
|
|
652
652
|
(result, sqlEquals) => {
|
653
653
|
it(`should update pilot where '${odata}'`, () => {
|
654
654
|
sqlEquals(
|
655
|
-
result
|
655
|
+
result,
|
656
656
|
`\
|
657
657
|
UPDATE "pilot"
|
658
658
|
SET "name" = ?
|
@@ -714,7 +714,7 @@ ${updateWhere}`,
|
|
714
714
|
test(`/pilot?$filter=${odata}`, 'DELETE', bindings, (result, sqlEquals) => {
|
715
715
|
it('should delete from pilot where "' + odata + '"', () => {
|
716
716
|
sqlEquals(
|
717
|
-
result
|
717
|
+
result,
|
718
718
|
`\
|
719
719
|
DELETE FROM "pilot"
|
720
720
|
WHERE "pilot"."id" IN ((
|
@@ -745,7 +745,7 @@ run(function () {
|
|
745
745
|
(result, sqlEquals) => {
|
746
746
|
it(`should insert into pilot where '${odata}'`, () => {
|
747
747
|
sqlEquals(
|
748
|
-
result
|
748
|
+
result,
|
749
749
|
`\
|
750
750
|
INSERT INTO "pilot" ("name")
|
751
751
|
SELECT "$insert"."name"
|
@@ -789,7 +789,7 @@ run(function () {
|
|
789
789
|
(result, sqlEquals) => {
|
790
790
|
it('should update the pilot with id 1', () => {
|
791
791
|
sqlEquals(
|
792
|
-
result
|
792
|
+
result,
|
793
793
|
`\
|
794
794
|
UPDATE "pilot"
|
795
795
|
SET "name" = ?
|
@@ -879,7 +879,7 @@ run(function () {
|
|
879
879
|
'should select from pilot__can_fly__plane where "' + odata + '"',
|
880
880
|
() => {
|
881
881
|
sqlEquals(
|
882
|
-
result
|
882
|
+
result,
|
883
883
|
`\
|
884
884
|
SELECT ${aliasPilotCanFlyPlaneFieldsStr}
|
885
885
|
FROM "pilot",
|
@@ -1013,7 +1013,7 @@ test(
|
|
1013
1013
|
(result, sqlEquals) => {
|
1014
1014
|
it('should select from pilot where ...', () => {
|
1015
1015
|
sqlEquals(
|
1016
|
-
result
|
1016
|
+
result,
|
1017
1017
|
`\
|
1018
1018
|
SELECT ${pilotFieldsStr}
|
1019
1019
|
FROM "pilot"
|
@@ -1036,7 +1036,7 @@ test(
|
|
1036
1036
|
(result, sqlEquals) => {
|
1037
1037
|
it('should select count(*) from pilot where ...', () => {
|
1038
1038
|
sqlEquals(
|
1039
|
-
result
|
1039
|
+
result,
|
1040
1040
|
`\
|
1041
1041
|
SELECT COUNT(*) AS "$count"
|
1042
1042
|
FROM "pilot"
|
@@ -1065,7 +1065,7 @@ test(
|
|
1065
1065
|
(result, sqlEquals) => {
|
1066
1066
|
it('should select count(*) from pilot where id in (5,10)', () => {
|
1067
1067
|
sqlEquals(
|
1068
|
-
result
|
1068
|
+
result,
|
1069
1069
|
`\
|
1070
1070
|
SELECT ${pilotFieldsStr}
|
1071
1071
|
FROM "pilot"
|
@@ -1098,7 +1098,7 @@ test(
|
|
1098
1098
|
(result, sqlEquals) => {
|
1099
1099
|
it('should select count(*) from pilot where id in (5,10)', () => {
|
1100
1100
|
sqlEquals(
|
1101
|
-
result
|
1101
|
+
result,
|
1102
1102
|
`\
|
1103
1103
|
SELECT ${pilotFieldsStr}
|
1104
1104
|
FROM "pilot"
|
@@ -1127,7 +1127,7 @@ test(
|
|
1127
1127
|
(result, sqlEquals) => {
|
1128
1128
|
it('should select from pilot where ...', () => {
|
1129
1129
|
sqlEquals(
|
1130
|
-
result
|
1130
|
+
result,
|
1131
1131
|
`\
|
1132
1132
|
SELECT ${pilotFieldsStr}
|
1133
1133
|
FROM "pilot"
|
@@ -1152,7 +1152,7 @@ test(
|
|
1152
1152
|
(result, sqlEquals) => {
|
1153
1153
|
it('should select count(*) from pilot where ...', () => {
|
1154
1154
|
sqlEquals(
|
1155
|
-
result
|
1155
|
+
result,
|
1156
1156
|
`\
|
1157
1157
|
SELECT COUNT(*) AS "$count"
|
1158
1158
|
FROM "pilot"
|
@@ -1177,7 +1177,7 @@ test(
|
|
1177
1177
|
(result, sqlEquals) => {
|
1178
1178
|
it('should select from pilot where ...', () => {
|
1179
1179
|
sqlEquals(
|
1180
|
-
result
|
1180
|
+
result,
|
1181
1181
|
`\
|
1182
1182
|
SELECT ${pilotFieldsStr}
|
1183
1183
|
FROM "pilot"
|
@@ -1200,7 +1200,7 @@ test(
|
|
1200
1200
|
(result, sqlEquals) => {
|
1201
1201
|
it('should select count(*) from pilot where ...', () => {
|
1202
1202
|
sqlEquals(
|
1203
|
-
result
|
1203
|
+
result,
|
1204
1204
|
`\
|
1205
1205
|
SELECT COUNT(*) AS "$count"
|
1206
1206
|
FROM "pilot"
|
@@ -1223,7 +1223,7 @@ test(
|
|
1223
1223
|
(result, sqlEquals) => {
|
1224
1224
|
it('should select from pilot where ...', () => {
|
1225
1225
|
sqlEquals(
|
1226
|
-
result
|
1226
|
+
result,
|
1227
1227
|
`\
|
1228
1228
|
SELECT ${pilotFieldsStr}
|
1229
1229
|
FROM "pilot"
|
@@ -1248,7 +1248,7 @@ test(
|
|
1248
1248
|
(result, sqlEquals) => {
|
1249
1249
|
it('should select count(*) from pilot where ...', () => {
|
1250
1250
|
sqlEquals(
|
1251
|
-
result
|
1251
|
+
result,
|
1252
1252
|
`\
|
1253
1253
|
SELECT COUNT(*) AS "$count"
|
1254
1254
|
FROM "pilot"
|
@@ -1279,7 +1279,7 @@ test(
|
|
1279
1279
|
(result, sqlEquals) => {
|
1280
1280
|
it('should select count(*) from pilot where id in (5,10)', () => {
|
1281
1281
|
sqlEquals(
|
1282
|
-
result
|
1282
|
+
result,
|
1283
1283
|
`\
|
1284
1284
|
SELECT ${pilotFieldsStr}
|
1285
1285
|
FROM "pilot"
|
@@ -1312,7 +1312,7 @@ test(
|
|
1312
1312
|
(result, sqlEquals) => {
|
1313
1313
|
it('should select count(*) from pilot where id in (5,10)', () => {
|
1314
1314
|
sqlEquals(
|
1315
|
-
result
|
1315
|
+
result,
|
1316
1316
|
`\
|
1317
1317
|
SELECT ${pilotFieldsStr}
|
1318
1318
|
FROM "pilot"
|
@@ -1345,7 +1345,7 @@ test(
|
|
1345
1345
|
(result, sqlEquals) => {
|
1346
1346
|
it('should select count(*) from pilot where id in (5,10)', () => {
|
1347
1347
|
sqlEquals(
|
1348
|
-
result
|
1348
|
+
result,
|
1349
1349
|
`\
|
1350
1350
|
SELECT ${pilotFieldsStr}
|
1351
1351
|
FROM "pilot"
|
@@ -1378,12 +1378,12 @@ run(function () {
|
|
1378
1378
|
test(
|
1379
1379
|
'/team?$filter=' + odata,
|
1380
1380
|
'POST',
|
1381
|
-
[['Bind', ['team', 'favourite_colour']]]
|
1381
|
+
[['Bind', ['team', 'favourite_colour']], ...bindings],
|
1382
1382
|
{ favourite_colour: favouriteColour },
|
1383
1383
|
(result, sqlEquals) => {
|
1384
1384
|
it('should insert into team where "' + odata + '"', () => {
|
1385
1385
|
sqlEquals(
|
1386
|
-
result
|
1386
|
+
result,
|
1387
1387
|
`\
|
1388
1388
|
INSERT INTO "team" ("favourite colour")
|
1389
1389
|
SELECT "$insert"."favourite colour"
|
@@ -1412,7 +1412,7 @@ run(function () {
|
|
1412
1412
|
test('/team?$filter=' + odata, 'GET', bindings, (result, sqlEquals) => {
|
1413
1413
|
it('should select from team where "' + odata + '"', () => {
|
1414
1414
|
sqlEquals(
|
1415
|
-
result
|
1415
|
+
result,
|
1416
1416
|
`\
|
1417
1417
|
SELECT ${teamFieldsStr}
|
1418
1418
|
FROM "team"
|
@@ -1430,7 +1430,7 @@ run(function () {
|
|
1430
1430
|
test(`/pilot?$filter=${odata}`, 'GET', [], (result, sqlEquals) => {
|
1431
1431
|
it('should select from pilot where "' + odata + '"', () => {
|
1432
1432
|
sqlEquals(
|
1433
|
-
result
|
1433
|
+
result,
|
1434
1434
|
`\
|
1435
1435
|
SELECT ${pilotFieldsStr}
|
1436
1436
|
FROM "pilot"
|
@@ -1442,7 +1442,7 @@ WHERE CURRENT_TIMESTAMP - DATE_TRUNC('milliseconds', "pilot"."created at") < INT
|
|
1442
1442
|
|
1443
1443
|
run(function () {
|
1444
1444
|
const odata = 'now() add now()';
|
1445
|
-
test(`/pilot?$filter=${odata}`, 'GET', [], (result, sqlEquals) => {
|
1445
|
+
test.fail(`/pilot?$filter=${odata}`, 'GET', [], (result, sqlEquals) => {
|
1446
1446
|
it(
|
1447
1447
|
'should fail to add current_timestamp to current_timestamp where "' +
|
1448
1448
|
odata +
|
@@ -1460,7 +1460,7 @@ run(function () {
|
|
1460
1460
|
test(`/pilot?$filter=${odata}`, 'GET', [], (result, sqlEquals) => {
|
1461
1461
|
it('should select from pilot where "' + odata + '"', () => {
|
1462
1462
|
sqlEquals(
|
1463
|
-
result
|
1463
|
+
result,
|
1464
1464
|
`\
|
1465
1465
|
SELECT ${pilotFieldsStr}
|
1466
1466
|
FROM "pilot"
|
@@ -1475,7 +1475,7 @@ run(function () {
|
|
1475
1475
|
test(`/pilot?$filter=${odata}`, 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
1476
1476
|
it('should select from pilot where "' + odata + '"', () => {
|
1477
1477
|
sqlEquals(
|
1478
|
-
result
|
1478
|
+
result,
|
1479
1479
|
`\
|
1480
1480
|
SELECT ${pilotFieldsStr}
|
1481
1481
|
FROM "pilot"
|
package/test/odata/orderby.js
CHANGED
@@ -5,7 +5,7 @@ const pilotFieldsStr = pilotFields.join(', ');
|
|
5
5
|
test('/pilot?$orderby=name', (result, sqlEquals) => {
|
6
6
|
it('should order by name desc', () => {
|
7
7
|
sqlEquals(
|
8
|
-
result
|
8
|
+
result,
|
9
9
|
`\
|
10
10
|
SELECT ${pilotFieldsStr}
|
11
11
|
FROM "pilot"
|
@@ -17,7 +17,7 @@ ORDER BY "pilot"."name" DESC`,
|
|
17
17
|
test('/pilot?$orderby=name,age', (result, sqlEquals) => {
|
18
18
|
it('should order by name desc, age desc', () => {
|
19
19
|
sqlEquals(
|
20
|
-
result
|
20
|
+
result,
|
21
21
|
`\
|
22
22
|
SELECT ${pilotFieldsStr}
|
23
23
|
FROM "pilot"
|
@@ -30,7 +30,7 @@ ORDER BY "pilot"."name" DESC,
|
|
30
30
|
test('/pilot?$orderby=name desc', (result, sqlEquals) => {
|
31
31
|
it('should order by name desc', () => {
|
32
32
|
sqlEquals(
|
33
|
-
result
|
33
|
+
result,
|
34
34
|
`\
|
35
35
|
SELECT ${pilotFieldsStr}
|
36
36
|
FROM "pilot"
|
@@ -42,7 +42,7 @@ ORDER BY "pilot"."name" DESC`,
|
|
42
42
|
test('/pilot?$orderby=name asc', (result, sqlEquals) => {
|
43
43
|
it('should order by name asc', () => {
|
44
44
|
sqlEquals(
|
45
|
-
result
|
45
|
+
result,
|
46
46
|
`\
|
47
47
|
SELECT ${pilotFieldsStr}
|
48
48
|
FROM "pilot"
|
@@ -54,7 +54,7 @@ ORDER BY "pilot"."name" ASC`,
|
|
54
54
|
test('/pilot?$orderby=name asc,age desc', (result, sqlEquals) => {
|
55
55
|
it('should order by name desc, age desc', () => {
|
56
56
|
sqlEquals(
|
57
|
-
result
|
57
|
+
result,
|
58
58
|
`\
|
59
59
|
SELECT ${pilotFieldsStr}
|
60
60
|
FROM "pilot"
|
@@ -67,7 +67,7 @@ ORDER BY "pilot"."name" ASC,
|
|
67
67
|
test('/pilot?$orderby=licence/id asc', (result, sqlEquals) => {
|
68
68
|
it('should order by licence/id asc', () => {
|
69
69
|
sqlEquals(
|
70
|
-
result
|
70
|
+
result,
|
71
71
|
`\
|
72
72
|
SELECT ${pilotFieldsStr}
|
73
73
|
FROM "pilot"
|
@@ -80,7 +80,7 @@ ORDER BY "pilot.licence"."id" ASC`,
|
|
80
80
|
test('/pilot?$orderby=can_fly__plane/plane/id asc', (result, sqlEquals) => {
|
81
81
|
it('should order by pilot__can_fly__plane/plane/id asc', () => {
|
82
82
|
sqlEquals(
|
83
|
-
result
|
83
|
+
result,
|
84
84
|
`\
|
85
85
|
SELECT ${pilotFieldsStr}
|
86
86
|
FROM "pilot"
|
@@ -91,6 +91,6 @@ ORDER BY "pilot.pilot-can fly-plane.plane"."id" ASC`,
|
|
91
91
|
});
|
92
92
|
});
|
93
93
|
|
94
|
-
test.
|
94
|
+
test.fail('/pilot?$orderby=favourite_colour/red', () => {
|
95
95
|
it("should order by how red the pilot's favourite colour is");
|
96
96
|
});
|
package/test/odata/paging.js
CHANGED
@@ -5,7 +5,7 @@ const pilotFieldsStr = pilotFields.join(', ');
|
|
5
5
|
test('/pilot?$top=5', 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
6
6
|
it('should select from pilot limited by 5', () => {
|
7
7
|
sqlEquals(
|
8
|
-
result
|
8
|
+
result,
|
9
9
|
`\
|
10
10
|
SELECT ${pilotFieldsStr}
|
11
11
|
FROM "pilot"
|
@@ -17,7 +17,7 @@ LIMIT ?`,
|
|
17
17
|
test('/pilot?$skip=100', 'GET', [['Bind', 0]], (result, sqlEquals) => {
|
18
18
|
it('should select from pilot offset by 100', () => {
|
19
19
|
sqlEquals(
|
20
|
-
result
|
20
|
+
result,
|
21
21
|
`\
|
22
22
|
SELECT ${pilotFieldsStr}
|
23
23
|
FROM "pilot"
|
@@ -36,7 +36,7 @@ test(
|
|
36
36
|
(result, sqlEquals) => {
|
37
37
|
it('should select from pilot limited by 5 and offset by 100', () => {
|
38
38
|
sqlEquals(
|
39
|
-
result
|
39
|
+
result,
|
40
40
|
`\
|
41
41
|
SELECT ${pilotFieldsStr}
|
42
42
|
FROM "pilot"
|