@abaplint/transpiler-cli 2.5.47 → 2.5.48

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.
Files changed (2) hide show
  1. package/build/bundle.js +54 -10
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -68271,6 +68271,7 @@ __exportStar(__webpack_require__(/*! ./source_field_symbol */ "./node_modules/@a
68271
68271
  __exportStar(__webpack_require__(/*! ./source_field */ "./node_modules/@abaplint/transpiler/build/src/expressions/source_field.js"), exports);
68272
68272
  __exportStar(__webpack_require__(/*! ./source */ "./node_modules/@abaplint/transpiler/build/src/expressions/source.js"), exports);
68273
68273
  __exportStar(__webpack_require__(/*! ./sql_cond */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_cond.js"), exports);
68274
+ __exportStar(__webpack_require__(/*! ./sql_field */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field.js"), exports);
68274
68275
  __exportStar(__webpack_require__(/*! ./sql_from */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_from.js"), exports);
68275
68276
  __exportStar(__webpack_require__(/*! ./sql_join */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_join.js"), exports);
68276
68277
  __exportStar(__webpack_require__(/*! ./sql_source_simple */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_source_simple.js"), exports);
@@ -69212,6 +69213,33 @@ exports.SQLCondTranspiler = SQLCondTranspiler;
69212
69213
 
69213
69214
  /***/ }),
69214
69215
 
69216
+ /***/ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field.js":
69217
+ /*!******************************************************************************!*\
69218
+ !*** ./node_modules/@abaplint/transpiler/build/src/expressions/sql_field.js ***!
69219
+ \******************************************************************************/
69220
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
69221
+
69222
+ "use strict";
69223
+
69224
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
69225
+ exports.SQLField = void 0;
69226
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
69227
+ class SQLField {
69228
+ transpile(node, _traversal) {
69229
+ const chunk = new chunk_1.Chunk();
69230
+ let concat = node.concatTokens();
69231
+ if (concat.includes("~") && concat.split("~")[0].includes("/")) {
69232
+ concat = "'" + concat.replace("~", "'~");
69233
+ }
69234
+ chunk.appendString(concat);
69235
+ return chunk;
69236
+ }
69237
+ }
69238
+ exports.SQLField = SQLField;
69239
+ //# sourceMappingURL=sql_field.js.map
69240
+
69241
+ /***/ }),
69242
+
69215
69243
  /***/ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_from.js":
69216
69244
  /*!*****************************************************************************!*\
69217
69245
  !*** ./node_modules/@abaplint/transpiler/build/src/expressions/sql_from.js ***!
@@ -69230,6 +69258,7 @@ class SQLFromTranspiler {
69230
69258
  const chunk = new chunk_1.Chunk();
69231
69259
  for (const c of node.getChildren()) {
69232
69260
  if (c instanceof abaplint.Nodes.TokenNode) {
69261
+ // keywords
69233
69262
  chunk.appendString(c.concatTokens() + " ");
69234
69263
  }
69235
69264
  else if (c.get() instanceof abaplint.Expressions.SQLJoin) {
@@ -69237,7 +69266,15 @@ class SQLFromTranspiler {
69237
69266
  chunk.appendString(" ");
69238
69267
  }
69239
69268
  else {
69240
- chunk.appendString(c.concatTokens() + " ");
69269
+ if (c.findFirstExpression(abaplint.Expressions.Dynamic)) {
69270
+ chunk.appendString(c.concatTokens() + " ");
69271
+ }
69272
+ else if (c.concatTokens().includes("/")) {
69273
+ chunk.appendString("'" + c.concatTokens() + "' ");
69274
+ }
69275
+ else {
69276
+ chunk.appendString(c.concatTokens() + " ");
69277
+ }
69241
69278
  }
69242
69279
  }
69243
69280
  return chunk;
@@ -74637,14 +74674,17 @@ class SelectTranspiler {
74637
74674
  let select = "SELECT ";
74638
74675
  const fieldList = node.findFirstExpression(abaplint.Expressions.SQLFieldList)
74639
74676
  || node.findFirstExpression(abaplint.Expressions.SQLFieldListLoop);
74640
- if ((fieldList === null || fieldList === void 0 ? void 0 : fieldList.getChildren().length) === 1) {
74641
- select += fieldList.concatTokens();
74642
- }
74643
- else {
74644
- // add commas between field names, this is required for SQLite, and easy to remove in other clients?
74645
- select += fieldList === null || fieldList === void 0 ? void 0 : fieldList.findAllExpressions(abaplint.Expressions.SQLField).map(e => e.concatTokens()).join(", ");
74677
+ const fields = [];
74678
+ for (const f of (fieldList === null || fieldList === void 0 ? void 0 : fieldList.getChildren()) || []) {
74679
+ if (f instanceof abaplint.Nodes.ExpressionNode && f.get() instanceof abaplint.Expressions.SQLField) {
74680
+ const code = new expressions_1.SQLField().transpile(f, traversal).getCode();
74681
+ fields.push(code);
74682
+ }
74683
+ else {
74684
+ fields.push(f.concatTokens());
74685
+ }
74646
74686
  }
74647
- select += " ";
74687
+ select += fields.join(", ") + " ";
74648
74688
  const from = node.findFirstExpression(abaplint.Expressions.SQLFrom);
74649
74689
  if (from) {
74650
74690
  select += new sql_from_1.SQLFromTranspiler().transpile(from, traversal).getCode();
@@ -74698,6 +74738,10 @@ class SelectTranspiler {
74698
74738
  const faeTranspiled = new expressions_1.SQLSourceTranspiler().transpile(fn, traversal).getCode();
74699
74739
  select = select.replace(new RegExp(" " + escapeRegExp(faeTranspiled), "g"), " " + unique);
74700
74740
  select = select.replace(unique + ".get().table_line.get()", unique + ".get()"); // there can be only one?
74741
+ let by = `Object.keys(${target}.getRowType().get())`;
74742
+ if (keys.length > 0) {
74743
+ by = JSON.stringify(keys);
74744
+ }
74701
74745
  const code = `if (${faeTranspiled}.array().length === 0) {
74702
74746
  throw "FAE, todo, empty table";
74703
74747
  } else {
@@ -74705,8 +74749,8 @@ class SelectTranspiler {
74705
74749
  for await (const ${unique} of abap.statements.loop(${faeTranspiled})) {
74706
74750
  await abap.statements.select(${target}, {select: "${select.trim()}"${extra}}, {appending: true});
74707
74751
  }
74708
- abap.statements.sort(${target}, {by: Object.keys(${target}.getRowType().get()).map(k => { return {component: k}; })});
74709
- await abap.statements.deleteInternal(${target}, {adjacent: true});
74752
+ abap.statements.sort(${target}, {by: ${by}.map(k => { return {component: k}; })});
74753
+ await abap.statements.deleteInternal(${target}, {adjacent: true, by: ${by}});
74710
74754
  abap.builtin.sy.get().dbcnt.set(${target}.array().length);
74711
74755
  }`;
74712
74756
  return new chunk_1.Chunk().append(code, node, traversal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.5.47",
3
+ "version": "2.5.48",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,7 +25,7 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.5.47",
28
+ "@abaplint/transpiler": "^2.5.48",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",