@abaplint/transpiler-cli 2.4.3 → 2.4.5

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 +31 -10
  2. package/package.json +2 -2
package/build/bundle.js CHANGED
@@ -68491,6 +68491,7 @@ exports.SourceFieldSymbolTranspiler = SourceFieldSymbolTranspiler;
68491
68491
  Object.defineProperty(exports, "__esModule", ({ value: true }));
68492
68492
  exports.SQLCondTranspiler = void 0;
68493
68493
  const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
68494
+ const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
68494
68495
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
68495
68496
  const simple_source3_1 = __webpack_require__(/*! ./simple_source3 */ "./node_modules/@abaplint/transpiler/build/src/expressions/simple_source3.js");
68496
68497
  const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
@@ -68518,7 +68519,7 @@ class SQLCondTranspiler {
68518
68519
  ret += this.sqlIn(c, traversal);
68519
68520
  }
68520
68521
  else {
68521
- ret += this.basicCondition(c, traversal);
68522
+ ret += this.basicCondition(c, traversal, traversal.getFilename());
68522
68523
  }
68523
68524
  }
68524
68525
  else if (c instanceof abaplint.Nodes.ExpressionNode) {
@@ -68541,39 +68542,59 @@ class SQLCondTranspiler {
68541
68542
  const ret = `" + abap.expandIN("${fieldName.concatTokens()}", ${source.concatTokens()}) + "`;
68542
68543
  return ret;
68543
68544
  }
68544
- basicCondition(c, traversal) {
68545
+ basicCondition(c, traversal, filename) {
68545
68546
  let ret = "";
68546
68547
  if (c.getChildren().length !== 3) {
68547
- return this.basicConditionNew(c, traversal);
68548
- // throw new Error("SQL Condition, transpiler todo1, " + c.concatTokens() + ", " + c.getChildren().length);
68548
+ return this.basicConditionNew(c, traversal, filename);
68549
68549
  }
68550
68550
  const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName);
68551
68551
  const operator = c.findDirectExpression(abaplint.Expressions.SQLCompareOperator);
68552
68552
  const source = c.findDirectExpression(abaplint.Expressions.SQLSource);
68553
68553
  if (fieldName && source && operator === undefined && c.findDirectTokenByText("LIKE")) {
68554
68554
  ret += fieldName.concatTokens() + " LIKE ";
68555
- ret += this.sqlSource(source, traversal);
68555
+ ret += this.sqlSource(source, traversal, filename);
68556
68556
  return ret;
68557
68557
  }
68558
68558
  if (fieldName === undefined || operator === undefined || source === undefined) {
68559
68559
  throw new Error("SQL Condition, transpiler todo2, " + c.concatTokens());
68560
68560
  }
68561
- ret += fieldName.concatTokens() + " " + operator.concatTokens() + " ";
68562
- ret += this.sqlSource(source, traversal);
68561
+ let op = operator.concatTokens();
68562
+ if (op.toUpperCase() === "EQ") {
68563
+ op = "=";
68564
+ }
68565
+ else if (op.toUpperCase() === "NE") {
68566
+ op = "<>";
68567
+ }
68568
+ ret += fieldName.concatTokens() + " " + op + " ";
68569
+ ret += this.sqlSource(source, traversal, filename);
68563
68570
  return ret;
68564
68571
  }
68565
- sqlSource(source, traversal) {
68572
+ sqlSource(source, traversal, filename) {
68566
68573
  let ret = "";
68567
68574
  const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
68575
+ const alias = source.findDirectExpression(abaplint.Expressions.SQLAliasField);
68568
68576
  if (simple && simple.findDirectExpression(abaplint.Expressions.Constant) === undefined) {
68569
68577
  ret += "'\" + " + new simple_source3_1.SimpleSource3Transpiler(true).transpile(simple, traversal).getCode() + " + \"'";
68570
68578
  }
68579
+ else if (alias) {
68580
+ // SQLAliasField might be a SQL reference or value from ABAP interface
68581
+ const pre = alias.concatTokens().split("~")[0];
68582
+ const found = traversal.findInterfaceDefinition(pre, traversal.findCurrentScopeByToken(alias.getFirstToken()));
68583
+ if (found) {
68584
+ let name = traversal.prefixAndName(alias.getFirstToken(), filename).replace("~", "$");
68585
+ name = traversal_1.Traversal.escapeNamespace(name);
68586
+ ret += "'\" + " + name + ".get() + \"'";
68587
+ }
68588
+ else {
68589
+ ret += source.concatTokens();
68590
+ }
68591
+ }
68571
68592
  else {
68572
68593
  ret += source.concatTokens();
68573
68594
  }
68574
68595
  return ret;
68575
68596
  }
68576
- basicConditionNew(node, traversal) {
68597
+ basicConditionNew(node, traversal, filename) {
68577
68598
  let ret = "";
68578
68599
  for (const child of node.getChildren()) {
68579
68600
  if (ret !== "") {
@@ -68584,7 +68605,7 @@ class SQLCondTranspiler {
68584
68605
  }
68585
68606
  else if (child.get() instanceof abaplint.Expressions.SQLSource
68586
68607
  && child instanceof abaplint.Nodes.ExpressionNode) {
68587
- ret += this.sqlSource(child, traversal);
68608
+ ret += this.sqlSource(child, traversal, filename);
68588
68609
  }
68589
68610
  else {
68590
68611
  ret += child.concatTokens();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.4.3",
3
+ "version": "2.4.5",
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.4.3",
28
+ "@abaplint/transpiler": "^2.4.5",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",