@abaplint/transpiler 2.13.85 → 2.13.86

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.
@@ -85,8 +85,10 @@ class ConstantTranspiler {
85
85
  return new chunk_1.Chunk(`todo, Constant`);
86
86
  }
87
87
  handleCharacter(res) {
88
- const foo = res.replace(/''/g, "'");
89
- let length = foo.length - 2;
88
+ // length of the value: strip the enclosing quotes first, an escaped
89
+ // quote ('') inside counts as one character and must not merge with them
90
+ const inner = res.substring(1, res.length - 1).replace(/''/g, "'");
91
+ let length = inner.length;
90
92
  if (length <= 0) {
91
93
  // note: Characters cannot have length = zero, 1 is minimum
92
94
  length = 1;
@@ -117,7 +117,8 @@ globalThis.abap = new runtime.ABAP();\n`;
117
117
  || obj instanceof abaplint.Objects.Oauth2Profile
118
118
  || obj instanceof abaplint.Objects.WebMIME
119
119
  || obj instanceof abaplint.Objects.TypePool
120
- || obj instanceof abaplint.Objects.TableType) {
120
+ || obj instanceof abaplint.Objects.TableType
121
+ || obj instanceof abaplint.Objects.View) {
121
122
  list.push(imp(`${escapeNamespaceFilename(obj.getName().toLowerCase())}.${obj.getType().toLowerCase()}`));
122
123
  }
123
124
  }
@@ -93,9 +93,11 @@ class SelectTranspiler {
93
93
  where = sqlCond;
94
94
  }
95
95
  }
96
+ let whereClause = "";
96
97
  if (where) {
97
- select += "WHERE " + new expressions_1.SQLCondTranspiler().transpile(where, traversal, table).getCode() + " ";
98
+ whereClause = "WHERE " + new expressions_1.SQLCondTranspiler().transpile(where, traversal, table).getCode() + " ";
98
99
  }
100
+ select += whereClause;
99
101
  const groupBy = node.findFirstExpression(abaplint.Expressions.SQLGroupBy);
100
102
  if (groupBy) {
101
103
  select += new sql_group_by_1.SQLGroupByTranspiler().transpile(groupBy, traversal).getCode() + " ";
@@ -136,6 +138,7 @@ class SelectTranspiler {
136
138
  else {
137
139
  const code = new expressions_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();
138
140
  select = select.replace(search, `" + ${code} + "`);
141
+ whereClause = whereClause.replace(search, `" + ${code} + "`);
139
142
  }
140
143
  }
141
144
  }
@@ -163,14 +166,17 @@ class SelectTranspiler {
163
166
  const unique2 = unique_identifier_1.UniqueIdentifier.get();
164
167
  const fn = node.findFirstExpression(abaplint.Expressions.SQLForAllEntries)?.findDirectExpression(abaplint.Expressions.SQLSource);
165
168
  const faeTranspiled = new expressions_1.SQLSourceTranspiler().transpile(fn, traversal).getCode();
169
+ // ABAP semantics: with an empty driving table the whole WHERE condition is ignored
170
+ const selectEmpty = select.replace(whereClause, "");
166
171
  select = select.replace(new RegExp(" " + escapeRegExp(faeTranspiled), "g"), " " + unique);
167
172
  select = select.replace(unique + ".get().table_line.get()", unique + ".get()"); // there can be only one?
168
- let by = `Object.keys(${target}.getRowType().get())`;
169
- if (keys.length > 0) {
170
- by = JSON.stringify(keys);
171
- }
173
+ // FOR ALL ENTRIES removes duplicate rows from the result: duplicates of
174
+ // the selected columns, so de-duplicate by the target's components. The
175
+ // DB key alone is wrong for projections (INTO CORRESPONDING FIELDS
176
+ // without the key fields crashed on the missing component names)
177
+ const by = `Object.keys(${target}.getRowType().get())`;
172
178
  const code = `if (${faeTranspiled}.array().length === 0) {
173
- throw new Error("FAE, todo, empty table");
179
+ await abap.statements.select(${target}, {select: "${selectEmpty.trim()}"${extra}});
174
180
  } else {
175
181
  const ${unique2} = ${faeTranspiled}.array();
176
182
  ${target}.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.13.85",
3
+ "version": "2.13.86",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -29,14 +29,14 @@
29
29
  "author": "abaplint",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "@abaplint/core": "^2.120.48",
32
+ "@abaplint/core": "^2.120.50",
33
33
  "source-map": "^0.8.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/chai": "^5.2.3",
37
37
  "@types/mocha": "^10.0.10",
38
38
  "chai": "^6.2.2",
39
- "mocha": "^12.0.0",
39
+ "mocha": "^12.0.1",
40
40
  "source-map-support": "^0.5.21",
41
41
  "typescript": "^6.0.3"
42
42
  }