@balena/lf-to-abstract-sql 4.5.5 → 4.5.6

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,3 +1,15 @@
1
+ - commits:
2
+ - subject: Stop using legacy/deprecated format for table aliases
3
+ hash: aa18d8cd7733e5250f9dfb2415904e9fc5a0c4b6
4
+ body: ""
5
+ footer:
6
+ Change-type: patch
7
+ change-type: patch
8
+ author: Pagan Gazzard
9
+ nested: []
10
+ version: 4.5.6
11
+ title: ""
12
+ date: 2022-11-29T14:16:21.062Z
1
13
  - commits:
2
14
  - subject: Update @balena/sbvr-parser from 1.4.1 to 1.4.2
3
15
  hash: 66473607a0ad66965d6660c94d8941e312282a6c
@@ -11,7 +23,7 @@
11
23
  nested: []
12
24
  version: 4.5.5
13
25
  title: ""
14
- date: 2022-11-17T08:47:24.825Z
26
+ date: 2022-11-17T08:50:36.617Z
15
27
  - commits:
16
28
  - subject: Add .npmrc
17
29
  hash: a2569a1953c937353ec94139a137283d719b9de3
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ 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
+ ## 4.5.6 - 2022-11-29
8
+
9
+ * Stop using legacy/deprecated format for table aliases [Pagan Gazzard]
10
+
7
11
  ## 4.5.5 - 2022-11-17
8
12
 
9
13
  * Update @balena/sbvr-parser from 1.4.1 to 1.4.2 [Josh Bowling]
@@ -677,7 +677,7 @@ var OMeta = require("ometa-js/lib/ometajs/core"), SBVRCompilerLibs = require("./
677
677
  binds = this._applyWithArgs("RoleBindings", actualFactType);
678
678
  tableAlias = this._applyWithArgs("LinkTableAlias", binds, actualFactType);
679
679
  linkTable = this._applyWithArgs("GetTable", actualFactType);
680
- query = [ "SelectQuery", [ "Select", [] ], [ "From", [ linkTable.name, tableAlias ] ] ];
680
+ query = [ "SelectQuery", [ "Select", [] ], [ "From", [ "Alias", [ "Table", linkTable.name ], tableAlias ] ] ];
681
681
  binds.forEach(function(bind, i) {
682
682
  var baseIdentifierName = actualFactType[2 * i][1];
683
683
  if (!$elf.GetTable(baseIdentifierName).primitive) {
@@ -1301,7 +1301,7 @@ LF2AbstractSQL.CreateConceptTypesResolver = function(query, identifier, varNum)
1301
1301
  var conceptTable, conceptAlias;
1302
1302
  if (0 === conceptTypeResolutions.length) {
1303
1303
  conceptTypeResolutions.push(identifier.name);
1304
- query.push([ "From", [ this.GetTable(identifier.name).name, parentAlias ] ]);
1304
+ query.push([ "From", [ "Alias", [ "Table", this.GetTable(identifier.name).name ], parentAlias ] ]);
1305
1305
  this.ResolveLinkTable(parentAlias);
1306
1306
  }
1307
1307
  parentAlias = _.last(conceptTypeResolutions);
@@ -1310,7 +1310,7 @@ LF2AbstractSQL.CreateConceptTypesResolver = function(query, identifier, varNum)
1310
1310
  conceptAlias = concept[1] + varNum;
1311
1311
  conceptTable = this.GetTable(concept[1]);
1312
1312
  if (!1 !== conceptTable.primitive) break;
1313
- query.push([ "From", [ conceptTable.name, conceptAlias ] ]);
1313
+ query.push([ "From", [ "Alias", [ "Table", conceptTable.name ], conceptAlias ] ]);
1314
1314
  this.AddWhereClause(query, [ "Equals", [ "ReferencedField", parentAlias, concept[1] ], [ "ReferencedField", conceptAlias, conceptTable.idField ] ]);
1315
1315
  this.ResolveLinkTable(parentAlias);
1316
1316
  parentAlias = conceptAlias;
@@ -554,7 +554,7 @@ export ometa LF2AbstractSQL <: SBVRCompilerLibs {
554
554
  RoleBindings(actualFactType):binds
555
555
  LinkTableAlias(binds, actualFactType):tableAlias
556
556
  GetTable(actualFactType):linkTable
557
- {['SelectQuery', ['Select', []], ['From', [linkTable.name, tableAlias]]]}:query
557
+ {['SelectQuery', ['Select', []], ['From', ['Alias', ['Table', linkTable.name], tableAlias]]]}:query
558
558
  { binds.forEach(function(bind, i) {
559
559
  var baseIdentifierName = actualFactType[i*2][1],
560
560
  targetTable = $elf.GetTable(baseIdentifierName);
@@ -1112,7 +1112,7 @@ LF2AbstractSQL.CreateConceptTypesResolver = function(query, identifier, varNum)
1112
1112
  if (conceptTypeResolutions.length === 0) {
1113
1113
  // Resolve the initial level on first call
1114
1114
  conceptTypeResolutions.push(identifier.name);
1115
- query.push(['From', [this.GetTable(identifier.name).name, parentAlias]])
1115
+ query.push(['From', ['Alias', ['Table', this.GetTable(identifier.name).name], parentAlias]])
1116
1116
  this.ResolveLinkTable(parentAlias);
1117
1117
  }
1118
1118
 
@@ -1128,7 +1128,7 @@ LF2AbstractSQL.CreateConceptTypesResolver = function(query, identifier, varNum)
1128
1128
  if(conceptTable.primitive !== false) {
1129
1129
  break;
1130
1130
  }
1131
- query.push(['From', [conceptTable.name, conceptAlias]]);
1131
+ query.push(['From', ['Alias', ['Table', conceptTable.name], conceptAlias]]);
1132
1132
  this.AddWhereClause(query, ['Equals', ['ReferencedField', parentAlias, concept[1]], ['ReferencedField', conceptAlias, conceptTable.idField]]);
1133
1133
  this.ResolveLinkTable(parentAlias);
1134
1134
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balena/lf-to-abstract-sql",
3
- "version": "4.5.5",
3
+ "version": "4.5.6",
4
4
  "description": "LF to Abstract SQL translator.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,13 +16,13 @@
16
16
  "author": "",
17
17
  "license": "BSD",
18
18
  "dependencies": {
19
- "@balena/sbvr-parser": "^1.4.2",
19
+ "@balena/sbvr-parser": "^1.4.3",
20
20
  "lodash": "^4.17.21",
21
21
  "ometa-js": "^1.5.4"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@balena/lint": "^6.2.1",
25
- "@balena/sbvr-types": "^3.4.8",
25
+ "@balena/sbvr-types": "^3.4.18",
26
26
  "chai": "^4.3.7",
27
27
  "mocha": "^10.1.0",
28
28
  "require-npm4-to-publish": "^1.0.0"
@@ -35,6 +35,6 @@
35
35
  "_": "test/**/*.js"
36
36
  },
37
37
  "versionist": {
38
- "publishedAt": "2022-11-17T08:47:25.024Z"
38
+ "publishedAt": "2022-11-29T14:16:21.278Z"
39
39
  }
40
40
  }
package/test/pilots.js CHANGED
@@ -136,7 +136,7 @@ describe('pilots', function () {
136
136
  [
137
137
  'SelectQuery',
138
138
  ['Select', []],
139
- ['From', ['pilot', 'pilot.0']],
139
+ ['From', ['Alias', ['Table', 'pilot'], 'pilot.0']],
140
140
  [
141
141
  'Where',
142
142
  [
@@ -148,7 +148,11 @@ describe('pilots', function () {
148
148
  ['Select', []],
149
149
  [
150
150
  'From',
151
- ['pilot-can fly-plane', 'pilot.0-can fly-plane.1'],
151
+ [
152
+ 'Alias',
153
+ ['Table', 'pilot-can fly-plane'],
154
+ 'pilot.0-can fly-plane.1',
155
+ ],
152
156
  ],
153
157
  [
154
158
  'Where',
@@ -486,7 +486,14 @@ exports.TableSpace = function () {
486
486
  const query = [
487
487
  'SelectQuery',
488
488
  ['Select', []],
489
- ['From', [generateName(termName), termName + '.' + varNum]],
489
+ [
490
+ 'From',
491
+ [
492
+ 'Alias',
493
+ ['Table', generateName(termName)],
494
+ termName + '.' + varNum,
495
+ ],
496
+ ],
490
497
  ];
491
498
  let extra = [];
492
499
  if (lf.length === 4) {
@@ -586,7 +593,7 @@ exports.TableSpace = function () {
586
593
  }
587
594
 
588
595
  return [
589
- ['From', [tableName, tableAlias]],
596
+ ['From', ['Alias', ['Table', tableName], tableAlias]],
590
597
  [
591
598
  'Where',
592
599
  ['And'].concat(
@@ -711,8 +718,8 @@ const stripLinkTable = (sql, tableAliases) =>
711
718
  return false;
712
719
  }
713
720
 
714
- // Remove [ 'From', [ tableName', tableAlias ] ]
715
- if (sqlPart[0] === 'From' && tableAliases.includes(sqlPart[1][1])) {
721
+ // Remove [ 'From', [ 'Alias', [ 'Table', tableName' ], tableAlias ] ]
722
+ if (sqlPart[0] === 'From' && tableAliases.includes(sqlPart[1][2])) {
716
723
  return true;
717
724
  }
718
725