@abaplint/transpiler 2.1.19 → 2.1.22

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.
@@ -24,10 +24,11 @@ class SQLiteDatabaseSchema {
24
24
  }
25
25
  const fields = [];
26
26
  for (const field of type.getComponents()) {
27
- fields.push(field.name.toLowerCase() + " " + this.toType(field.type, field.name, tabl.getName()));
27
+ fields.push("'" + field.name.toLowerCase() + "' " + this.toType(field.type, field.name, tabl.getName()));
28
28
  }
29
29
  // assumption: all transparent tables have primary keys
30
- const key = ", PRIMARY KEY(" + tabl.listKeys().map(e => e.toLowerCase()).join(",") + ")";
30
+ // add single quotes to field names to allow for keywords as field names
31
+ const key = ", PRIMARY KEY(" + tabl.listKeys().map(e => "'" + e.toLowerCase() + "'").join(",") + ")";
31
32
  return `CREATE TABLE ${tabl.getName().toLowerCase()} (${fields.join(", ")}${key});\n`;
32
33
  }
33
34
  toType(type, fieldname, table) {
@@ -57,6 +58,10 @@ class SQLiteDatabaseSchema {
57
58
  else if (type instanceof abaplint.BasicTypes.IntegerType) {
58
59
  return `INT`;
59
60
  }
61
+ else if (type instanceof abaplint.BasicTypes.FloatType
62
+ || type instanceof abaplint.BasicTypes.FloatingPointType) {
63
+ return `REAL`;
64
+ }
60
65
  else if (type instanceof abaplint.BasicTypes.PackedType) {
61
66
  return `DECIMAL(${type.getLength()},${type.getDecimals()})`;
62
67
  }
@@ -7,7 +7,7 @@ const expressions_1 = require("../expressions");
7
7
  const unique_identifier_1 = require("../unique_identifier");
8
8
  class SelectTranspiler {
9
9
  transpile(node, traversal, targetOverride) {
10
- var _a, _b, _c, _d, _e, _f;
10
+ var _a, _b, _c, _d;
11
11
  let target = "undefined";
12
12
  if (targetOverride) {
13
13
  target = targetOverride;
@@ -16,9 +16,17 @@ class SelectTranspiler {
16
16
  target = traversal.traverse(node.findFirstExpression(abaplint.Expressions.Target)).getCode();
17
17
  }
18
18
  let select = "SELECT ";
19
- select += (((_a = node.findFirstExpression(abaplint.Expressions.SQLFieldList)) === null || _a === void 0 ? void 0 : _a.concatTokens())
20
- || ((_b = node.findFirstExpression(abaplint.Expressions.SQLFieldListLoop)) === null || _b === void 0 ? void 0 : _b.concatTokens())) + " ";
21
- select += ((_c = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _c === void 0 ? void 0 : _c.concatTokens()) + " ";
19
+ const fieldList = node.findFirstExpression(abaplint.Expressions.SQLFieldList)
20
+ || node.findFirstExpression(abaplint.Expressions.SQLFieldListLoop);
21
+ if ((fieldList === null || fieldList === void 0 ? void 0 : fieldList.getChildren().length) === 1) {
22
+ select += fieldList.concatTokens();
23
+ }
24
+ else {
25
+ // add commas between field names, this is required for SQLite, and easy to remove in other clients?
26
+ select += fieldList === null || fieldList === void 0 ? void 0 : fieldList.findAllExpressions(abaplint.Expressions.SQLField).map(e => e.concatTokens()).join(", ");
27
+ }
28
+ select += " ";
29
+ select += ((_a = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _a === void 0 ? void 0 : _a.concatTokens()) + " ";
22
30
  let where;
23
31
  for (const sqlCond of node.findAllExpressions(abaplint.Expressions.SQLCond)) {
24
32
  if (this.isWhereExpression(node, sqlCond)) {
@@ -58,7 +66,7 @@ class SelectTranspiler {
58
66
  }
59
67
  if (node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) {
60
68
  const unique = unique_identifier_1.UniqueIdentifier.get();
61
- const faeName = (_f = (_e = (_d = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) === null || _d === void 0 ? void 0 : _d.findDirectExpression(abaplint.Expressions.SQLSource)) === null || _e === void 0 ? void 0 : _e.concatTokens()) === null || _f === void 0 ? void 0 : _f.toLowerCase();
69
+ const faeName = (_d = (_c = (_b = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(abaplint.Expressions.SQLSource)) === null || _c === void 0 ? void 0 : _c.concatTokens()) === null || _d === void 0 ? void 0 : _d.toLowerCase();
62
70
  select = select.replace(new RegExp(" " + faeName, "g"), " " + unique);
63
71
  select = select.replace(unique + ".get().table_line.get()", unique + ".get()"); // there can be only one?
64
72
  const code = `if (${faeName}.array().length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.1.19",
3
+ "version": "2.1.22",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "author": "abaplint",
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@abaplint/core": "^2.91.19",
31
+ "@abaplint/core": "^2.91.25",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {