From 1fcaedb0135232343c2bb2cb1b82abe93972b18d Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Mon, 8 Jul 2024 09:08:38 +0200 Subject: [PATCH] fix --- .../transpiler/src/statements/delete_internal.ts | 15 +++++++++++---- test/statements/delete_internal.ts | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/transpiler/src/statements/delete_internal.ts b/packages/transpiler/src/statements/delete_internal.ts index 049b74a51..5b68f726b 100644 --- a/packages/transpiler/src/statements/delete_internal.ts +++ b/packages/transpiler/src/statements/delete_internal.ts @@ -6,14 +6,21 @@ import {Chunk} from "../chunk"; export class DeleteInternalTranspiler implements IStatementTranspiler { public transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk { - const target = traversal.traverse(node.findFirstExpression(abaplint.Expressions.Target)).getCode(); + const target = traversal.traverse(node.findDirectExpression(abaplint.Expressions.Target)).getCode(); const concat = node.concatTokens().toUpperCase(); const extra: string[] = []; - const where = node.findFirstExpression(abaplint.Expressions.ComponentCond); - if (where) { + + const componentCond = node.findDirectExpression(abaplint.Expressions.ComponentCond); + if (componentCond) { // todo, replacing "await" is a hack - extra.push("where: " + traversal.traverse(where).getCode().replace("await ", "")); + extra.push("where: " + traversal.traverse(componentCond).getCode().replace("await ", "")); + } + + const componentCompare = node.findDirectExpression(abaplint.Expressions.ComponentCompare); + if (componentCompare) { + // todo: this can be optimized, WITH TABLE KEY + extra.push("where: " + traversal.traverse(componentCompare).getCode()); } // todo, this is not completely correct, fields might have the name ADJACENT diff --git a/test/statements/delete_internal.ts b/test/statements/delete_internal.ts index 3da09770c..7895f1b7f 100644 --- a/test/statements/delete_internal.ts +++ b/test/statements/delete_internal.ts @@ -470,7 +470,7 @@ ENDLOOP.`; expect(abap.console.get()).to.equal("6\n3\n10"); }); - it.only("DELETE, with table key", async () => { + it("DELETE, with table key", async () => { const code = ` TYPES: BEGIN OF ty, foobar TYPE i,