@abaplint/transpiler-cli 2.13.66 → 2.13.68

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 +94 -2
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -106897,6 +106897,8 @@ const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@
106897
106897
  const sql_field_name_1 = __webpack_require__(/*! ./sql_field_name */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_name.js");
106898
106898
  const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
106899
106899
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/transpiler/build/src/expressions/source.js");
106900
+ const sql_field_list_1 = __webpack_require__(/*! ./sql_field_list */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_list.js");
106901
+ const sql_from_1 = __webpack_require__(/*! ./sql_from */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_from.js");
106900
106902
  class SQLCondTranspiler {
106901
106903
  transpile(node, traversal, table) {
106902
106904
  let ret = "";
@@ -106926,6 +106928,9 @@ class SQLCondTranspiler {
106926
106928
  else if (c.findDirectExpression(abaplint.Expressions.SQLIn)) {
106927
106929
  ret += this.sqlIn(c, traversal, traversal.getFilename(), table);
106928
106930
  }
106931
+ else if (this.findSubselect(c)) {
106932
+ ret += this.subselectCondition(c, traversal, table);
106933
+ }
106929
106934
  else {
106930
106935
  ret += this.basicCondition(c, traversal, traversal.getFilename(), table);
106931
106936
  }
@@ -106944,14 +106949,22 @@ class SQLCondTranspiler {
106944
106949
  const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName)
106945
106950
  || c.findDirectExpression(abaplint.Expressions.SQLAliasField);
106946
106951
  const sqlin = c.findDirectExpression(abaplint.Expressions.SQLIn);
106947
- const source = c.findFirstExpression(abaplint.Expressions.SimpleSource3);
106948
- if (fieldName === undefined || sqlin === undefined || source === undefined) {
106952
+ const subselect = sqlin === undefined ? undefined : this.findSubselect(sqlin);
106953
+ if (fieldName === undefined || sqlin === undefined) {
106949
106954
  throw new Error("SQL Condition, transpiler todo, " + c.concatTokens());
106950
106955
  }
106951
106956
  let pre = "";
106952
106957
  if (c.concatTokens().toUpperCase().includes(" NOT IN ")) {
106953
106958
  pre = "NOT ";
106954
106959
  }
106960
+ if (subselect) {
106961
+ const field = new sql_field_name_1.SQLFieldNameTranspiler().transpile(fieldName, traversal).getCode();
106962
+ return `${field} ${pre}IN ${this.sqlSubselect(subselect, traversal, table)}`;
106963
+ }
106964
+ const source = c.findFirstExpression(abaplint.Expressions.SimpleSource3);
106965
+ if (source === undefined) {
106966
+ throw new Error("SQL Condition, transpiler todo, " + c.concatTokens());
106967
+ }
106955
106968
  if (sqlin.getChildren().length === 2) {
106956
106969
  const s = new source_1.SourceTranspiler().transpile(source, traversal).getCode();
106957
106970
  return `${pre}" + abap.expandIN("${fieldName.concatTokens()}", ${s}) + "`;
@@ -106969,6 +106982,10 @@ class SQLCondTranspiler {
106969
106982
  }
106970
106983
  basicCondition(c, traversal, filename, table) {
106971
106984
  let ret = "";
106985
+ const subselect = this.findSubselect(c);
106986
+ if (subselect) {
106987
+ return this.subselectCondition(c, traversal, table);
106988
+ }
106972
106989
  if (c.getChildren().length !== 3) {
106973
106990
  return this.basicConditionNew(c, traversal, filename, table);
106974
106991
  }
@@ -106997,6 +107014,59 @@ class SQLCondTranspiler {
106997
107014
  ret += this.sqlSource(source, traversal, filename, table);
106998
107015
  return ret;
106999
107016
  }
107017
+ subselectCondition(c, traversal, table) {
107018
+ const subselect = this.findSubselect(c);
107019
+ if (subselect === undefined) {
107020
+ throw new Error("SQL Condition, subselect not found, " + c.concatTokens());
107021
+ }
107022
+ const fieldNameExpression = c.findDirectExpression(abaplint.Expressions.SQLFieldName)
107023
+ || c.findDirectExpression(abaplint.Expressions.SQLAliasField);
107024
+ const operator = c.findDirectExpression(abaplint.Expressions.SQLCompareOperator);
107025
+ if (fieldNameExpression && operator) {
107026
+ const fieldName = new sql_field_name_1.SQLFieldNameTranspiler().transpile(fieldNameExpression, traversal).getCode();
107027
+ const quantifier = c.getChildren().find(child => child instanceof abaplint.Nodes.TokenNode
107028
+ && ["ALL", "ANY", "SOME"].includes(child.getFirstToken().getStr().toUpperCase()));
107029
+ const suffix = quantifier ? " " + quantifier.concatTokens() : "";
107030
+ return `${fieldName} ${this.sqlOperator(operator.concatTokens())}${suffix} ${this.sqlSubselect(subselect, traversal, table)}`;
107031
+ }
107032
+ if (c.findDirectTokenByText("EXISTS")) {
107033
+ const not = c.findDirectTokenByText("NOT") ? "NOT " : "";
107034
+ return `${not}EXISTS ${this.sqlSubselect(subselect, traversal, table)}`;
107035
+ }
107036
+ throw new Error("SQL Condition, unsupported subselect, " + c.concatTokens());
107037
+ }
107038
+ findSubselect(node) {
107039
+ const grouped = node.findDirectExpression(abaplint.Expressions.SQLSetOpGroup);
107040
+ if (grouped) {
107041
+ return grouped;
107042
+ }
107043
+ // Older parser releases represent the scalar form as an inline sequence
107044
+ // instead of wrapping it in SQLSetOpGroup.
107045
+ if (node.getTokens().some(token => token.getStr().toUpperCase() === "SELECT")) {
107046
+ return node;
107047
+ }
107048
+ return undefined;
107049
+ }
107050
+ sqlSubselect(node, traversal, table) {
107051
+ const fieldList = node.findFirstExpression(abaplint.Expressions.SQLFieldList);
107052
+ const from = node.findFirstExpression(abaplint.Expressions.SQLFrom);
107053
+ if (fieldList === undefined || from === undefined) {
107054
+ throw new Error("SQL Condition, malformed subselect, " + node.concatTokens());
107055
+ }
107056
+ const tokens = node.getTokens();
107057
+ const selectIndex = tokens.findIndex(token => token.getStr().toUpperCase() === "SELECT");
107058
+ const distinct = selectIndex >= 0 && tokens[selectIndex + 1]?.getStr().toUpperCase() === "DISTINCT";
107059
+ let ret = `(SELECT${distinct ? " DISTINCT" : ""} `;
107060
+ ret += new sql_field_list_1.SQLFieldListTranspiler().transpile(fieldList, traversal).getCode();
107061
+ ret += " " + new sql_from_1.SQLFromTranspiler().transpile(from, traversal).getCode().trim();
107062
+ const where = node.findFirstExpression(abaplint.Expressions.SQLCond);
107063
+ if (where) {
107064
+ const subTable = from.findFirstExpression(abaplint.Expressions.DatabaseTable);
107065
+ const conditionTable = subTable ? traversal.findTable(subTable.concatTokens()) : table;
107066
+ ret += " WHERE " + new SQLCondTranspiler().transpile(where, traversal, conditionTable).getCode();
107067
+ }
107068
+ return ret + ")";
107069
+ }
107000
107070
  sqlSource(source, traversal, filename, table) {
107001
107071
  let ret = "";
107002
107072
  const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
@@ -120356,6 +120426,27 @@ exports.CaseTypeTranspiler = CaseTypeTranspiler;
120356
120426
 
120357
120427
  /***/ },
120358
120428
 
120429
+ /***/ "./node_modules/@abaplint/transpiler/build/src/structures/catch_system_exceptions.js"
120430
+ /*!*******************************************************************************************!*\
120431
+ !*** ./node_modules/@abaplint/transpiler/build/src/structures/catch_system_exceptions.js ***!
120432
+ \*******************************************************************************************/
120433
+ (__unused_webpack_module, exports, __webpack_require__) {
120434
+
120435
+ "use strict";
120436
+
120437
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
120438
+ exports.CatchSystemExceptionsTranspiler = void 0;
120439
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
120440
+ class CatchSystemExceptionsTranspiler {
120441
+ transpile(node, traversal) {
120442
+ return new chunk_1.Chunk().append(`throw new Error("CATCH SYSTEM-EXCEPTIONS, not supported, transpiler");`, node, traversal);
120443
+ }
120444
+ }
120445
+ exports.CatchSystemExceptionsTranspiler = CatchSystemExceptionsTranspiler;
120446
+ //# sourceMappingURL=catch_system_exceptions.js.map
120447
+
120448
+ /***/ },
120449
+
120359
120450
  /***/ "./node_modules/@abaplint/transpiler/build/src/structures/class_definition.js"
120360
120451
  /*!************************************************************************************!*\
120361
120452
  !*** ./node_modules/@abaplint/transpiler/build/src/structures/class_definition.js ***!
@@ -121121,6 +121212,7 @@ __exportStar(__webpack_require__(/*! ./at_first */ "./node_modules/@abaplint/tra
121121
121212
  __exportStar(__webpack_require__(/*! ./at_last */ "./node_modules/@abaplint/transpiler/build/src/structures/at_last.js"), exports);
121122
121213
  __exportStar(__webpack_require__(/*! ./case_type */ "./node_modules/@abaplint/transpiler/build/src/structures/case_type.js"), exports);
121123
121214
  __exportStar(__webpack_require__(/*! ./case */ "./node_modules/@abaplint/transpiler/build/src/structures/case.js"), exports);
121215
+ __exportStar(__webpack_require__(/*! ./catch_system_exceptions */ "./node_modules/@abaplint/transpiler/build/src/structures/catch_system_exceptions.js"), exports);
121124
121216
  __exportStar(__webpack_require__(/*! ./class_definition */ "./node_modules/@abaplint/transpiler/build/src/structures/class_definition.js"), exports);
121125
121217
  __exportStar(__webpack_require__(/*! ./class_implementation */ "./node_modules/@abaplint/transpiler/build/src/structures/class_implementation.js"), exports);
121126
121218
  __exportStar(__webpack_require__(/*! ./constants */ "./node_modules/@abaplint/transpiler/build/src/structures/constants.js"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.13.66",
3
+ "version": "2.13.68",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
30
  "@abaplint/core": "^2.120.42",
31
- "@abaplint/transpiler": "^2.13.66",
31
+ "@abaplint/transpiler": "^2.13.68",
32
32
  "@types/glob": "^8.1.0",
33
33
  "@types/node": "^24.13.3",
34
34
  "@types/progress": "^2.0.7",