@balena/abstract-sql-compiler 10.2.4-build-renovate-major-22-node-81f07071cc94780a7385f50254cba5e9d8340e64-1 → 10.2.4-build-update-dev-deps-703263fa73aff2253d1a931a5946a027d20c9ff6-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.
@@ -1,16 +1,15 @@
1
1
  - commits:
2
- - subject: Update dependency @types/node to v22
3
- hash: 81f07071cc94780a7385f50254cba5e9d8340e64
4
- body: |
5
- Update @types/node from 20.17.24 to 22.13.10
2
+ - subject: Update dev dependencies
3
+ hash: 703263fa73aff2253d1a931a5946a027d20c9ff6
4
+ body: ""
6
5
  footer:
7
6
  Change-type: patch
8
7
  change-type: patch
9
- author: balena-renovate[bot]
8
+ author: Pagan Gazzard
10
9
  nested: []
11
10
  version: 10.2.4
12
11
  title: ""
13
- date: 2025-03-19T14:47:14.021Z
12
+ date: 2025-04-04T13:13:39.664Z
14
13
  - commits:
15
14
  - subject: "Tests: convert test/abstract-sql/case-when-else.js to typescript"
16
15
  hash: 0edb21cc4ee30ead2a6eeb290623f3a0adc7a0fe
package/CHANGELOG.md CHANGED
@@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file
4
4
  automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
5
5
  This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
- ## 10.2.4 - 2025-03-19
7
+ ## 10.2.4 - 2025-04-04
8
8
 
9
- * Update dependency @types/node to v22 [balena-renovate[bot]]
9
+ * Update dev dependencies [Pagan Gazzard]
10
10
 
11
11
  ## 10.2.3 - 2025-03-19
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balena/abstract-sql-compiler",
3
- "version": "10.2.4-build-renovate-major-22-node-81f07071cc94780a7385f50254cba5e9d8340e64-1",
3
+ "version": "10.2.4-build-update-dev-deps-703263fa73aff2253d1a931a5946a027d20c9ff6-1",
4
4
  "description": "A translator for abstract sql into sql.",
5
5
  "type": "commonjs",
6
6
  "main": "out/AbstractSQLCompiler.js",
@@ -23,23 +23,23 @@
23
23
  "@balena/sbvr-types": "^7.1.0 || ^8.0.0 || ^9.0.2"
24
24
  },
25
25
  "devDependencies": {
26
- "@balena/lf-to-abstract-sql": "^5.0.2",
26
+ "@balena/lf-to-abstract-sql": "^5.0.4",
27
27
  "@balena/lint": "^8.2.8",
28
- "@balena/odata-parser": "^3.1.0",
29
- "@balena/odata-to-abstract-sql": "^7.0.0",
30
- "@balena/sbvr-parser": "^1.4.6",
31
- "@types/chai": "^4.3.4",
28
+ "@balena/odata-parser": "^3.1.2",
29
+ "@balena/odata-to-abstract-sql": "^7.2.0",
30
+ "@balena/sbvr-parser": "^1.4.9",
31
+ "@types/chai": "^4.3.20",
32
32
  "@types/common-tags": "^1.8.4",
33
- "@types/lodash": "^4.17.10",
34
- "@types/mocha": "^10.0.8",
35
- "@types/node": "^22.0.0",
36
- "chai": "^4.3.7",
33
+ "@types/lodash": "^4.17.16",
34
+ "@types/mocha": "^10.0.10",
35
+ "@types/node": "^20.17.30",
36
+ "chai": "^4.5.0",
37
37
  "common-tags": "^1.8.2",
38
- "husky": "^9.1.6",
39
- "lint-staged": "^15.2.10",
40
- "mocha": "^11.0.0",
38
+ "husky": "^9.1.7",
39
+ "lint-staged": "^15.5.0",
40
+ "mocha": "^11.2.0",
41
41
  "ts-node": "^10.9.2",
42
- "typescript": "^5.6.2"
42
+ "typescript": "^5.8.2"
43
43
  },
44
44
  "lint-staged": {
45
45
  "*.js": [
@@ -64,6 +64,6 @@
64
64
  "npm": ">=10.7.0"
65
65
  },
66
66
  "versionist": {
67
- "publishedAt": "2025-03-19T14:47:14.379Z"
67
+ "publishedAt": "2025-04-04T13:13:40.067Z"
68
68
  }
69
69
  }
@@ -346,10 +346,9 @@ SELECT (
346
346
  SELECT ${aggFunc('"pilot.licence".*')} AS "licence"
347
347
  FROM (
348
348
  SELECT ${aliasLicenceFields.join(', ')}
349
- FROM "licence" AS "pilot.licence",
350
- "pilot" AS "pilot.licence.is of-pilot"
351
- WHERE "pilot.licence"."id" = "pilot.licence.is of-pilot"."licence"
352
- AND ("pilot.licence.is of-pilot"."id") IS NOT NULL AND ("pilot.licence.is of-pilot"."id") = (?)
349
+ FROM "licence" AS "pilot.licence"
350
+ LEFT JOIN "pilot" AS "pilot.licence.is of-pilot" ON "pilot.licence"."id" = "pilot.licence.is of-pilot"."licence"
351
+ WHERE ("pilot.licence.is of-pilot"."id") IS NOT NULL AND ("pilot.licence.is of-pilot"."id") = (?)
353
352
  AND "pilot"."licence" = "pilot.licence"."id"
354
353
  ) AS "pilot.licence"
355
354
  ) AS "licence", ${remainingPilotFields}
@@ -351,21 +351,15 @@ 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) => {
@@ -375,7 +369,7 @@ AND ` + sql;
375
369
  `\
376
370
  SELECT ${pilotFieldsStr}
377
371
  FROM ${from}
378
- WHERE ${where}`,
372
+ WHERE ${sql}`,
379
373
  );
380
374
  });
381
375
  });
@@ -390,7 +384,7 @@ WHERE ${where}`,
390
384
  `\
391
385
  SELECT COUNT(*) AS "$count"
392
386
  FROM ${from}
393
- WHERE ${where}`,
387
+ WHERE ${sql}`,
394
388
  );
395
389
  });
396
390
  },
@@ -563,10 +557,9 @@ run(function () {
563
557
  result.query,
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
  });
@@ -588,10 +581,9 @@ run(function () {
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
  );
@@ -609,11 +601,6 @@ run(function () {
609
601
  );
610
602
  const name = 'Peter';
611
603
  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
- ];
617
604
  const insertTest = (result, sqlEquals) => {
618
605
  sqlEquals(
619
606
  result.query,
@@ -625,22 +612,22 @@ 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) => {
@@ -649,10 +636,10 @@ WHERE "pilot"."id" IN ((
649
636
  result.query,
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
  });
@@ -732,10 +719,10 @@ ${updateWhere}`,
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
  });
@@ -1032,10 +1019,9 @@ 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
  );
@@ -1056,10 +1042,9 @@ 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
  );
@@ -1086,10 +1071,9 @@ 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") = (?)
@@ -1121,10 +1105,9 @@ 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") = (?)
@@ -1150,10 +1133,9 @@ 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
  )
@@ -1176,10 +1158,9 @@ 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
  )
@@ -1199,10 +1180,9 @@ test(
1199
1180
  result.query,
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"
@@ -1223,10 +1203,9 @@ test(
1223
1203
  result.query,
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"
@@ -1247,10 +1226,9 @@ test(
1247
1226
  result.query,
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"
@@ -1273,10 +1251,9 @@ test(
1273
1251
  result.query,
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"
@@ -1308,10 +1285,9 @@ 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") = (?)
@@ -1342,10 +1318,9 @@ 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") = (?))
@@ -1376,10 +1351,9 @@ 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") = (?))
@@ -1441,14 +1415,11 @@ run(function () {
1441
1415
  result.query,
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
  });
@@ -70,9 +70,8 @@ test('/pilot?$orderby=licence/id asc', (result, sqlEquals) => {
70
70
  result.query,
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
  });
@@ -84,11 +83,9 @@ test('/pilot?$orderby=can_fly__plane/plane/id asc', (result, sqlEquals) => {
84
83
  result.query,
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
  });
@@ -64,9 +64,8 @@ test('/pilot?$select=trained__pilot/name', (result, sqlEquals) => {
64
64
  result.query,
65
65
  `\
66
66
  SELECT "pilot.trained-pilot"."name"
67
- FROM "pilot",
68
- "pilot" AS "pilot.trained-pilot"
69
- WHERE "pilot"."id" = "pilot.trained-pilot"."was trained by-pilot"`,
67
+ FROM "pilot"
68
+ LEFT JOIN "pilot" AS "pilot.trained-pilot" ON "pilot"."id" = "pilot.trained-pilot"."was trained by-pilot"`,
70
69
  );
71
70
  });
72
71
  });
@@ -77,9 +76,8 @@ test('/pilot?$select=trained__pilot/name,age', (result, sqlEquals) => {
77
76
  result.query,
78
77
  `\
79
78
  SELECT "pilot.trained-pilot"."name", "pilot"."age"
80
- FROM "pilot",
81
- "pilot" AS "pilot.trained-pilot"
82
- WHERE "pilot"."id" = "pilot.trained-pilot"."was trained by-pilot"`,
79
+ FROM "pilot"
80
+ LEFT JOIN "pilot" AS "pilot.trained-pilot" ON "pilot"."id" = "pilot.trained-pilot"."was trained by-pilot"`,
83
81
  );
84
82
  });
85
83
  });
@@ -101,9 +99,8 @@ test('/pilot?$select=licence/id', (result, sqlEquals) => {
101
99
  result.query,
102
100
  `\
103
101
  SELECT "pilot.licence"."id"
104
- FROM "pilot",
105
- "licence" AS "pilot.licence"
106
- WHERE "pilot"."licence" = "pilot.licence"."id"`,
102
+ FROM "pilot"
103
+ LEFT JOIN "licence" AS "pilot.licence" ON "pilot"."licence" = "pilot.licence"."id"`,
107
104
  );
108
105
  });
109
106
  });
@@ -114,11 +111,9 @@ test('/pilot?$select=can_fly__plane/plane/id', (result, sqlEquals) => {
114
111
  result.query,
115
112
  `\
116
113
  SELECT "pilot.pilot-can fly-plane.plane"."id"
117
- FROM "pilot",
118
- "pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
119
- "plane" AS "pilot.pilot-can fly-plane.plane"
120
- WHERE "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
121
- AND "pilot.pilot-can fly-plane"."can fly-plane" = "pilot.pilot-can fly-plane.plane"."id"`,
114
+ FROM "pilot"
115
+ LEFT JOIN "pilot-can fly-plane" AS "pilot.pilot-can fly-plane" ON "pilot"."id" = "pilot.pilot-can fly-plane"."pilot"
116
+ 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"`,
122
117
  );
123
118
  });
124
119
  });