@abaplint/transpiler 2.11.83 → 2.11.85
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,10 +25,14 @@ class UpdateDatabaseTranspiler {
|
|
|
25
25
|
}
|
|
26
26
|
options.push(`"set": [${s.join(",")}]`);
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
28
|
+
const sourceExpression = node.findDirectExpression(abaplint.Expressions.SQLSource)?.findDirectExpression(abaplint.Expressions.SimpleSource3);
|
|
29
|
+
if (sourceExpression) {
|
|
30
|
+
const sqlSource = new expressions_1.SourceTranspiler(true).transpile(sourceExpression, traversal).getCode();
|
|
30
31
|
const tableName = node.findDirectExpression(abaplint.Expressions.DatabaseTable)?.concatTokens();
|
|
31
32
|
const tabl = traversal.findTable(tableName);
|
|
33
|
+
if (tabl === undefined) {
|
|
34
|
+
return new chunk_1.Chunk(`throw new Error("UpdateDatabaseTranspiler: table ${tableName} not found");`);
|
|
35
|
+
}
|
|
32
36
|
const keys = tabl.listKeys(traversal.reg).map(k => k.toLowerCase());
|
|
33
37
|
const allFields = tabl.parseType(traversal.reg).getComponents().map(c => {
|
|
34
38
|
return c.name.toLowerCase();
|
|
@@ -36,7 +40,7 @@ class UpdateDatabaseTranspiler {
|
|
|
36
40
|
const where = [];
|
|
37
41
|
const set = [];
|
|
38
42
|
for (const fieldName of allFields) {
|
|
39
|
-
const cond = `\\"${fieldName}\\" = '\" + ${sqlSource}
|
|
43
|
+
const cond = `\\"${fieldName}\\" = '\" + ${sqlSource}.${fieldName}.get() + \"'`;
|
|
40
44
|
if (keys.includes(fieldName) === true) {
|
|
41
45
|
where.push(cond);
|
|
42
46
|
}
|