@abaplint/transpiler 2.11.81 → 2.11.83

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.
@@ -25,6 +25,28 @@ class UpdateDatabaseTranspiler {
25
25
  }
26
26
  options.push(`"set": [${s.join(",")}]`);
27
27
  }
28
+ const sqlSource = node.findDirectExpression(abaplint.Expressions.SQLSource)?.concatTokens()?.toLowerCase().replace("@", "");
29
+ if (sqlSource) {
30
+ const tableName = node.findDirectExpression(abaplint.Expressions.DatabaseTable)?.concatTokens();
31
+ const tabl = traversal.findTable(tableName);
32
+ const keys = tabl.listKeys(traversal.reg).map(k => k.toLowerCase());
33
+ const allFields = tabl.parseType(traversal.reg).getComponents().map(c => {
34
+ return c.name.toLowerCase();
35
+ });
36
+ const where = [];
37
+ const set = [];
38
+ for (const fieldName of allFields) {
39
+ const cond = `\\"${fieldName}\\" = '\" + ${sqlSource}.get().${fieldName}.get() + \"'`;
40
+ if (keys.includes(fieldName) === true) {
41
+ where.push(cond);
42
+ }
43
+ else {
44
+ set.push("\"" + cond + "\"");
45
+ }
46
+ }
47
+ options.push(`"where": "` + where.join(" AND ") + `"`);
48
+ options.push(`"set": [${set.join(",")}]`);
49
+ }
28
50
  return new chunk_1.Chunk(`await abap.statements.updateDatabase(${table.getCode()}, {${options.join(", ")}});`);
29
51
  }
30
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.11.81",
3
+ "version": "2.11.83",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",