@balena/abstract-sql-compiler 10.2.4-build-renovate-major-22-node-81f07071cc94780a7385f50254cba5e9d8340e64-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.
@@ -351,31 +351,25 @@ const createMethodCall = function (method, ...args) {
351
351
  const operandTest = (lhs, op, rhs, override) => {
352
352
  run(function () {
353
353
  let from;
354
- let where;
355
354
  let { odata, sql, bindings } = createExpression(lhs, op, rhs);
356
355
  bindings = override?.bindings ?? bindings;
357
356
  sql = override?.sql ?? sql;
358
357
  if (_.includes(odata, '/')) {
359
358
  from = `\
360
- "pilot",
361
- "pilot" AS "pilot.trained-pilot"`;
362
- where =
363
- `\
364
- "pilot"."id" = "pilot.trained-pilot"."was trained by-pilot"
365
- AND ` + sql;
359
+ "pilot"
360
+ LEFT JOIN "pilot" AS "pilot.trained-pilot" ON "pilot"."id" = "pilot.trained-pilot"."was trained by-pilot"`;
366
361
  } else {
367
362
  from = '"pilot"';
368
- where = sql;
369
363
  }
370
364
 
371
365
  test(`/pilot?$filter=${odata}`, 'GET', bindings, (result, sqlEquals) => {
372
366
  it('should select from pilot where "' + odata + '"', () => {
373
367
  sqlEquals(
374
- result.query,
368
+ result,
375
369
  `\
376
370
  SELECT ${pilotFieldsStr}
377
371
  FROM ${from}
378
- WHERE ${where}`,
372
+ WHERE ${sql}`,
379
373
  );
380
374
  });
381
375
  });
@@ -386,11 +380,11 @@ WHERE ${where}`,
386
380
  (result, sqlEquals) => {
387
381
  it('should select count(*) from pilot where "' + odata + '"', () => {
388
382
  sqlEquals(
389
- result.query,
383
+ result,
390
384
  `\
391
385
  SELECT COUNT(*) AS "$count"
392
386
  FROM ${from}
393
- WHERE ${where}`,
387
+ WHERE ${sql}`,
394
388
  );
395
389
  });
396
390
  },
@@ -404,7 +398,7 @@ const methodTest = (...args) => {
404
398
  test(`/pilot?$filter=${odata}`, 'GET', bindings, (result, sqlEquals) => {
405
399
  it('should select from pilot where "' + odata + '"', () => {
406
400
  sqlEquals(
407
- result.query,
401
+ result,
408
402
  `\
409
403
  SELECT ${pilotFieldsStr}
410
404
  FROM "pilot"
@@ -419,7 +413,7 @@ WHERE ` + sql,
419
413
  (result, sqlEquals) => {
420
414
  it('should select count(*) from pilot where "' + odata + '"', () => {
421
415
  sqlEquals(
422
- result.query,
416
+ result,
423
417
  `\
424
418
  SELECT COUNT(*) AS "$count"
425
419
  FROM "pilot"
@@ -519,7 +513,7 @@ run(function () {
519
513
  (result, sqlEquals) => {
520
514
  it('should select from pilot where "' + odata + '"', () => {
521
515
  sqlEquals(
522
- result.query,
516
+ result,
523
517
  `\
524
518
  SELECT ${pilotFieldsStr}
525
519
  FROM "pilot"
@@ -539,7 +533,7 @@ run(function () {
539
533
  (result, sqlEquals) => {
540
534
  it('should select from pilot where "' + odata + '"', () => {
541
535
  sqlEquals(
542
- result.query,
536
+ result,
543
537
  `\
544
538
  SELECT ${pilotFieldsStr}
545
539
  FROM "pilot"
@@ -560,13 +554,12 @@ run(function () {
560
554
  test(`/pilot?$filter=${odata}`, 'GET', bindings, (result, sqlEquals) => {
561
555
  it('should select from pilot where "' + odata + '"', () => {
562
556
  sqlEquals(
563
- result.query,
557
+ result,
564
558
  `\
565
559
  SELECT ${pilotFieldsStr}
566
- FROM "pilot",
567
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
568
- WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
569
- AND ${sql}`,
560
+ FROM "pilot"
561
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
562
+ WHERE ${sql}`,
570
563
  );
571
564
  });
572
565
  });
@@ -584,14 +577,13 @@ run(function () {
584
577
  'should select from pilot__can_fly__plane where "' + odata + '"',
585
578
  () => {
586
579
  sqlEquals(
587
- result.query,
580
+ result,
588
581
  `\
589
582
  SELECT ${aliasPilotCanFlyPlaneFieldsStr}
590
583
  FROM "pilot",
591
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
592
- "plane" AS "pilot.pilot-can fly-plane.can fly-plane"
593
- WHERE "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.can fly-plane"."id"
594
- AND ("pilot.pilot-can fly-plane.can fly-plane"."id") IS NOT NULL AND ("pilot.pilot-can fly-plane.can fly-plane"."id") = (?)
584
+ "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
585
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.can fly-plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.can fly-plane"."id"
586
+ WHERE ("pilot.pilot-can fly-plane.can fly-plane"."id") IS NOT NULL AND ("pilot.pilot-can fly-plane.can fly-plane"."id") = (?)
595
587
  AND "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
596
588
  AND ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)`,
597
589
  );
@@ -608,15 +600,10 @@ run(function () {
608
600
  10,
609
601
  );
610
602
  const name = 'Peter';
611
- const bodyBindings = [['Bind', ['pilot', 'name']]].concat(bindings);
612
- const filterWhere = [
613
- 'WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"',
614
- 'AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"',
615
- `AND ${sql}`,
616
- ];
603
+ const bodyBindings = [['Bind', ['pilot', 'name']], ...bindings];
617
604
  const insertTest = (result, sqlEquals) => {
618
605
  sqlEquals(
619
- result.query,
606
+ result,
620
607
  `\
621
608
  INSERT INTO "pilot" ("name")
622
609
  SELECT "$insert"."name"
@@ -625,34 +612,34 @@ FROM (
625
612
  ) AS "$insert"
626
613
  WHERE EXISTS (
627
614
  SELECT 1
628
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
629
- "plane" AS "pilot.pilot-can fly-plane.plane",
630
- (
615
+ FROM (
631
616
  SELECT "$insert".*
632
617
  ) AS "pilot"
633
- ${filterWhere.join('\n\t')}
618
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
619
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
620
+ WHERE ${sql}
634
621
  )`,
635
622
  );
636
623
  };
637
624
  const updateWhere = `\
638
625
  WHERE "pilot"."id" IN ((
639
626
  SELECT "pilot"."id" AS "$modifyid"
640
- FROM "pilot",
641
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
642
- "plane" AS "pilot.pilot-can fly-plane.plane"
643
- ${filterWhere.join('\n\t')}
627
+ FROM "pilot"
628
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
629
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
630
+ WHERE ${sql}
644
631
  ))`;
645
632
 
646
633
  test(`/pilot?$filter=${odata}`, 'GET', bindings, (result, sqlEquals) => {
647
634
  it(`should select from pilot where '${odata}'`, () => {
648
635
  sqlEquals(
649
- result.query,
636
+ result,
650
637
  `\
651
638
  SELECT ${pilotFieldsStr}
652
- FROM "pilot",
653
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
654
- "plane" AS "pilot.pilot-can fly-plane.plane"
655
- ${filterWhere.join('\n')}`,
639
+ FROM "pilot"
640
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
641
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
642
+ WHERE ${sql}`,
656
643
  );
657
644
  });
658
645
  });
@@ -665,7 +652,7 @@ ${filterWhere.join('\n')}`,
665
652
  (result, sqlEquals) => {
666
653
  it(`should update pilot where '${odata}'`, () => {
667
654
  sqlEquals(
668
- result.query,
655
+ result,
669
656
  `\
670
657
  UPDATE "pilot"
671
658
  SET "name" = ?
@@ -727,15 +714,15 @@ ${updateWhere}`,
727
714
  test(`/pilot?$filter=${odata}`, 'DELETE', bindings, (result, sqlEquals) => {
728
715
  it('should delete from pilot where "' + odata + '"', () => {
729
716
  sqlEquals(
730
- result.query,
717
+ result,
731
718
  `\
732
719
  DELETE FROM "pilot"
733
720
  WHERE "pilot"."id" IN ((
734
721
  SELECT "pilot"."id" AS "$modifyid"
735
- FROM "pilot",
736
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
737
- "plane" AS "pilot.pilot-can fly-plane.plane"
738
- ${filterWhere.join('\n\t')}
722
+ FROM "pilot"
723
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
724
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
725
+ WHERE ${sql}
739
726
  ))`,
740
727
  );
741
728
  });
@@ -758,7 +745,7 @@ run(function () {
758
745
  (result, sqlEquals) => {
759
746
  it(`should insert into pilot where '${odata}'`, () => {
760
747
  sqlEquals(
761
- result.query,
748
+ result,
762
749
  `\
763
750
  INSERT INTO "pilot" ("name")
764
751
  SELECT "$insert"."name"
@@ -802,7 +789,7 @@ run(function () {
802
789
  (result, sqlEquals) => {
803
790
  it('should update the pilot with id 1', () => {
804
791
  sqlEquals(
805
- result.query,
792
+ result,
806
793
  `\
807
794
  UPDATE "pilot"
808
795
  SET "name" = ?
@@ -892,7 +879,7 @@ run(function () {
892
879
  'should select from pilot__can_fly__plane where "' + odata + '"',
893
880
  () => {
894
881
  sqlEquals(
895
- result.query,
882
+ result,
896
883
  `\
897
884
  SELECT ${aliasPilotCanFlyPlaneFieldsStr}
898
885
  FROM "pilot",
@@ -1026,16 +1013,15 @@ test(
1026
1013
  (result, sqlEquals) => {
1027
1014
  it('should select from pilot where ...', () => {
1028
1015
  sqlEquals(
1029
- result.query,
1016
+ result,
1030
1017
  `\
1031
1018
  SELECT ${pilotFieldsStr}
1032
1019
  FROM "pilot"
1033
1020
  WHERE EXISTS (
1034
1021
  SELECT 1
1035
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1036
- "plane" AS "pilot.pilot-can fly-plane.plane"
1022
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1023
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1037
1024
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1038
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1039
1025
  AND ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1040
1026
  )`,
1041
1027
  );
@@ -1050,16 +1036,15 @@ test(
1050
1036
  (result, sqlEquals) => {
1051
1037
  it('should select count(*) from pilot where ...', () => {
1052
1038
  sqlEquals(
1053
- result.query,
1039
+ result,
1054
1040
  `\
1055
1041
  SELECT COUNT(*) AS "$count"
1056
1042
  FROM "pilot"
1057
1043
  WHERE EXISTS (
1058
1044
  SELECT 1
1059
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1060
- "plane" AS "pilot.pilot-can fly-plane.plane"
1045
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1046
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1061
1047
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1062
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1063
1048
  AND ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1064
1049
  )`,
1065
1050
  );
@@ -1080,16 +1065,15 @@ test(
1080
1065
  (result, sqlEquals) => {
1081
1066
  it('should select count(*) from pilot where id in (5,10)', () => {
1082
1067
  sqlEquals(
1083
- result.query,
1068
+ result,
1084
1069
  `\
1085
1070
  SELECT ${pilotFieldsStr}
1086
1071
  FROM "pilot"
1087
1072
  WHERE (EXISTS (
1088
1073
  SELECT 1
1089
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1090
- "plane" AS "pilot.pilot-can fly-plane.plane"
1074
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1075
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1091
1076
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1092
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1093
1077
  AND ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1094
1078
  )
1095
1079
  OR ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)
@@ -1114,17 +1098,16 @@ test(
1114
1098
  (result, sqlEquals) => {
1115
1099
  it('should select count(*) from pilot where id in (5,10)', () => {
1116
1100
  sqlEquals(
1117
- result.query,
1101
+ result,
1118
1102
  `\
1119
1103
  SELECT ${pilotFieldsStr}
1120
1104
  FROM "pilot"
1121
1105
  WHERE NOT (
1122
1106
  (EXISTS (
1123
1107
  SELECT 1
1124
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1125
- "plane" AS "pilot.pilot-can fly-plane.plane"
1108
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1109
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1126
1110
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1127
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1128
1111
  AND ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1129
1112
  )
1130
1113
  OR ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)
@@ -1144,16 +1127,15 @@ test(
1144
1127
  (result, sqlEquals) => {
1145
1128
  it('should select from pilot where ...', () => {
1146
1129
  sqlEquals(
1147
- result.query,
1130
+ result,
1148
1131
  `\
1149
1132
  SELECT ${pilotFieldsStr}
1150
1133
  FROM "pilot"
1151
1134
  WHERE NOT EXISTS (
1152
1135
  SELECT 1
1153
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1154
- "plane" AS "pilot.pilot-can fly-plane.plane"
1136
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1137
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1155
1138
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1156
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1157
1139
  AND NOT (
1158
1140
  ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1159
1141
  )
@@ -1170,16 +1152,15 @@ test(
1170
1152
  (result, sqlEquals) => {
1171
1153
  it('should select count(*) from pilot where ...', () => {
1172
1154
  sqlEquals(
1173
- result.query,
1155
+ result,
1174
1156
  `\
1175
1157
  SELECT COUNT(*) AS "$count"
1176
1158
  FROM "pilot"
1177
1159
  WHERE NOT EXISTS (
1178
1160
  SELECT 1
1179
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1180
- "plane" AS "pilot.pilot-can fly-plane.plane"
1161
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1162
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1181
1163
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1182
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1183
1164
  AND NOT (
1184
1165
  ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1185
1166
  )
@@ -1196,13 +1177,12 @@ test(
1196
1177
  (result, sqlEquals) => {
1197
1178
  it('should select from pilot where ...', () => {
1198
1179
  sqlEquals(
1199
- result.query,
1180
+ result,
1200
1181
  `\
1201
1182
  SELECT ${pilotFieldsStr}
1202
- FROM "pilot",
1203
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1204
- WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1205
- AND EXISTS (
1183
+ FROM "pilot"
1184
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1185
+ WHERE EXISTS (
1206
1186
  SELECT 1
1207
1187
  FROM "plane" AS "pilot.pilot-can fly-plane.plane"
1208
1188
  WHERE "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
@@ -1220,13 +1200,12 @@ test(
1220
1200
  (result, sqlEquals) => {
1221
1201
  it('should select count(*) from pilot where ...', () => {
1222
1202
  sqlEquals(
1223
- result.query,
1203
+ result,
1224
1204
  `\
1225
1205
  SELECT COUNT(*) AS "$count"
1226
- FROM "pilot",
1227
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1228
- WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1229
- AND EXISTS (
1206
+ FROM "pilot"
1207
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1208
+ WHERE EXISTS (
1230
1209
  SELECT 1
1231
1210
  FROM "plane" AS "pilot.pilot-can fly-plane.plane"
1232
1211
  WHERE "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
@@ -1244,13 +1223,12 @@ test(
1244
1223
  (result, sqlEquals) => {
1245
1224
  it('should select from pilot where ...', () => {
1246
1225
  sqlEquals(
1247
- result.query,
1226
+ result,
1248
1227
  `\
1249
1228
  SELECT ${pilotFieldsStr}
1250
- FROM "pilot",
1251
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1252
- WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1253
- AND NOT EXISTS (
1229
+ FROM "pilot"
1230
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1231
+ WHERE NOT EXISTS (
1254
1232
  SELECT 1
1255
1233
  FROM "plane" AS "pilot.pilot-can fly-plane.plane"
1256
1234
  WHERE "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
@@ -1270,13 +1248,12 @@ test(
1270
1248
  (result, sqlEquals) => {
1271
1249
  it('should select count(*) from pilot where ...', () => {
1272
1250
  sqlEquals(
1273
- result.query,
1251
+ result,
1274
1252
  `\
1275
1253
  SELECT COUNT(*) AS "$count"
1276
- FROM "pilot",
1277
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1278
- WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1279
- AND NOT EXISTS (
1254
+ FROM "pilot"
1255
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1256
+ WHERE NOT EXISTS (
1280
1257
  SELECT 1
1281
1258
  FROM "plane" AS "pilot.pilot-can fly-plane.plane"
1282
1259
  WHERE "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
@@ -1302,16 +1279,15 @@ test(
1302
1279
  (result, sqlEquals) => {
1303
1280
  it('should select count(*) from pilot where id in (5,10)', () => {
1304
1281
  sqlEquals(
1305
- result.query,
1282
+ result,
1306
1283
  `\
1307
1284
  SELECT ${pilotFieldsStr}
1308
1285
  FROM "pilot"
1309
1286
  WHERE (EXISTS (
1310
1287
  SELECT 1
1311
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1312
- "plane" AS "pilot.pilot-can fly-plane.plane"
1288
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1289
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1313
1290
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1314
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1315
1291
  AND ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1316
1292
  )
1317
1293
  OR ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)
@@ -1336,16 +1312,15 @@ test(
1336
1312
  (result, sqlEquals) => {
1337
1313
  it('should select count(*) from pilot where id in (5,10)', () => {
1338
1314
  sqlEquals(
1339
- result.query,
1315
+ result,
1340
1316
  `\
1341
1317
  SELECT ${pilotFieldsStr}
1342
1318
  FROM "pilot"
1343
1319
  WHERE EXISTS (
1344
1320
  SELECT 1
1345
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1346
- "plane" AS "pilot.pilot-can fly-plane.plane"
1321
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1322
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1347
1323
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1348
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1349
1324
  AND ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1350
1325
  )
1351
1326
  AND NOT(("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?))
@@ -1370,16 +1345,15 @@ test(
1370
1345
  (result, sqlEquals) => {
1371
1346
  it('should select count(*) from pilot where id in (5,10)', () => {
1372
1347
  sqlEquals(
1373
- result.query,
1348
+ result,
1374
1349
  `\
1375
1350
  SELECT ${pilotFieldsStr}
1376
1351
  FROM "pilot"
1377
1352
  WHERE EXISTS (
1378
1353
  SELECT 1
1379
- FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
1380
- "plane" AS "pilot.pilot-can fly-plane.plane"
1354
+ FROM "pilot-can fly-plane" AS "pilot.pilot-can fly-plane"
1355
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1381
1356
  WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
1382
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
1383
1357
  AND ("pilot.pilot-can fly-plane.plane"."name") IS NOT NULL AND ("pilot.pilot-can fly-plane.plane"."name") = (?)
1384
1358
  )
1385
1359
  AND NOT(("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?))
@@ -1404,12 +1378,12 @@ run(function () {
1404
1378
  test(
1405
1379
  '/team?$filter=' + odata,
1406
1380
  'POST',
1407
- [['Bind', ['team', 'favourite_colour']]].concat(bindings),
1381
+ [['Bind', ['team', 'favourite_colour']], ...bindings],
1408
1382
  { favourite_colour: favouriteColour },
1409
1383
  (result, sqlEquals) => {
1410
1384
  it('should insert into team where "' + odata + '"', () => {
1411
1385
  sqlEquals(
1412
- result.query,
1386
+ result,
1413
1387
  `\
1414
1388
  INSERT INTO "team" ("favourite colour")
1415
1389
  SELECT "$insert"."favourite colour"
@@ -1438,17 +1412,14 @@ run(function () {
1438
1412
  test('/team?$filter=' + odata, 'GET', bindings, (result, sqlEquals) => {
1439
1413
  it('should select from team where "' + odata + '"', () => {
1440
1414
  sqlEquals(
1441
- result.query,
1415
+ result,
1442
1416
  `\
1443
1417
  SELECT ${teamFieldsStr}
1444
- FROM "team",
1445
- "pilot" AS "team.includes-pilot",
1446
- "pilot-can fly-plane" AS "team.includes-pilot.pilot-can fly-plane",
1447
- "plane" AS "team.includes-pilot.pilot-can fly-plane.plane"
1448
- WHERE "team"."favourite colour" = "team.includes-pilot"."is on-team"
1449
- AND "team.includes-pilot"."id" = "team.includes-pilot.pilot-can fly-plane"."pilot"
1450
- AND "team.includes-pilot.pilot-can fly-plane"."can fly-plane" = "team.includes-pilot.pilot-can fly-plane.plane"."id"
1451
- AND ${sql}`,
1418
+ FROM "team"
1419
+ LEFT JOIN "pilot" AS "team.includes-pilot" ON "team"."favourite colour" = "team.includes-pilot"."is on-team"
1420
+ LEFT JOIN "pilot-can fly-plane" AS "team.includes-pilot.pilot-can fly-plane" ON "team.includes-pilot"."id" = "team.includes-pilot.pilot-can fly-plane"."pilot"
1421
+ LEFT JOIN "plane" AS "team.includes-pilot.pilot-can fly-plane.plane" ON "team.includes-pilot.pilot-can fly-plane"."can fly-plane" = "team.includes-pilot.pilot-can fly-plane.plane"."id"
1422
+ WHERE ${sql}`,
1452
1423
  );
1453
1424
  });
1454
1425
  });
@@ -1459,7 +1430,7 @@ run(function () {
1459
1430
  test(`/pilot?$filter=${odata}`, 'GET', [], (result, sqlEquals) => {
1460
1431
  it('should select from pilot where "' + odata + '"', () => {
1461
1432
  sqlEquals(
1462
- result.query,
1433
+ result,
1463
1434
  `\
1464
1435
  SELECT ${pilotFieldsStr}
1465
1436
  FROM "pilot"
@@ -1471,7 +1442,7 @@ WHERE CURRENT_TIMESTAMP - DATE_TRUNC('milliseconds', "pilot"."created at") < INT
1471
1442
 
1472
1443
  run(function () {
1473
1444
  const odata = 'now() add now()';
1474
- test(`/pilot?$filter=${odata}`, 'GET', [], (result, sqlEquals) => {
1445
+ test.fail(`/pilot?$filter=${odata}`, 'GET', [], (result, sqlEquals) => {
1475
1446
  it(
1476
1447
  'should fail to add current_timestamp to current_timestamp where "' +
1477
1448
  odata +
@@ -1489,7 +1460,7 @@ run(function () {
1489
1460
  test(`/pilot?$filter=${odata}`, 'GET', [], (result, sqlEquals) => {
1490
1461
  it('should select from pilot where "' + odata + '"', () => {
1491
1462
  sqlEquals(
1492
- result.query,
1463
+ result,
1493
1464
  `\
1494
1465
  SELECT ${pilotFieldsStr}
1495
1466
  FROM "pilot"
@@ -1504,7 +1475,7 @@ run(function () {
1504
1475
  test(`/pilot?$filter=${odata}`, 'GET', [['Bind', 0]], (result, sqlEquals) => {
1505
1476
  it('should select from pilot where "' + odata + '"', () => {
1506
1477
  sqlEquals(
1507
- result.query,
1478
+ result,
1508
1479
  `\
1509
1480
  SELECT ${pilotFieldsStr}
1510
1481
  FROM "pilot"
@@ -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.query,
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.query,
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.query,
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.query,
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.query,
57
+ result,
58
58
  `\
59
59
  SELECT ${pilotFieldsStr}
60
60
  FROM "pilot"
@@ -67,12 +67,11 @@ 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.query,
70
+ result,
71
71
  `\
72
72
  SELECT ${pilotFieldsStr}
73
- FROM "pilot",
74
- "licence" AS "pilot.licence"
75
- WHERE "pilot"."licence" = "pilot.licence"."id"
73
+ FROM "pilot"
74
+ LEFT JOIN "licence" AS "pilot.licence" ON "pilot"."licence" = "pilot.licence"."id"
76
75
  ORDER BY "pilot.licence"."id" ASC`,
77
76
  );
78
77
  });
@@ -81,19 +80,17 @@ ORDER BY "pilot.licence"."id" ASC`,
81
80
  test('/pilot?$orderby=can_fly__plane/plane/id asc', (result, sqlEquals) => {
82
81
  it('should order by pilot__can_fly__plane/plane/id asc', () => {
83
82
  sqlEquals(
84
- result.query,
83
+ result,
85
84
  `\
86
85
  SELECT ${pilotFieldsStr}
87
- FROM "pilot",
88
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
89
- "plane" AS "pilot.pilot-can fly-plane.plane"
90
- WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
91
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
86
+ FROM "pilot"
87
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
88
+ LEFT JOIN "plane" AS "pilot.pilot-can fly-plane.plane" ON "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"
92
89
  ORDER BY "pilot.pilot-can fly-plane.plane"."id" ASC`,
93
90
  );
94
91
  });
95
92
  });
96
93
 
97
- test.skip('/pilot?$orderby=favourite_colour/red', () => {
94
+ test.fail('/pilot?$orderby=favourite_colour/red', () => {
98
95
  it("should order by how red the pilot's favourite colour is");
99
96
  });