@abaplint/runtime 2.4.5 → 2.4.7

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.
@@ -0,0 +1,2 @@
1
+ import { FieldSymbol } from "./types";
2
+ export declare function expandDynamic(code: string, ev: (name: string) => FieldSymbol | undefined): string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expandDynamic = void 0;
4
+ const types_1 = require("./types");
5
+ function expandDynamic(code, ev) {
6
+ if (code === "") {
7
+ return "1 = 1";
8
+ }
9
+ else {
10
+ // todo more here, this is just one simple case,
11
+ const match = code.match(/ <(\w+)>/);
12
+ if (match && match[1]) {
13
+ const name = "fs_" + match[1] + "_";
14
+ const found = ev(name);
15
+ if (found instanceof types_1.FieldSymbol) {
16
+ code = code.replace(/ <(\w+)>/, "'" + found.get() + "'");
17
+ }
18
+ }
19
+ return code;
20
+ }
21
+ }
22
+ exports.expandDynamic = expandDynamic;
23
+ //# sourceMappingURL=expand_dynamic.js.map
@@ -11,6 +11,7 @@ import * as operators from "./operators";
11
11
  import * as RFC from "./rfc";
12
12
  import * as types from "./types";
13
13
  import { expandIN } from "./expand_in";
14
+ import { expandDynamic } from "./expand_dynamic";
14
15
  import { ClassicError } from "./classic_error";
15
16
  export { UnitTestResult, RFC, types, DB };
16
17
  export declare class ABAP {
@@ -38,6 +39,7 @@ export declare class ABAP {
38
39
  OffsetLength: typeof OffsetLength;
39
40
  templateFormatting: typeof templateFormatting;
40
41
  expandIN: typeof expandIN;
42
+ expandDynamic: typeof expandDynamic;
41
43
  ClassicError: typeof ClassicError;
42
44
  readonly context: Context;
43
45
  constructor();
@@ -18,6 +18,7 @@ exports.RFC = RFC;
18
18
  const types = require("./types");
19
19
  exports.types = types;
20
20
  const expand_in_1 = require("./expand_in");
21
+ const expand_dynamic_1 = require("./expand_dynamic");
21
22
  const classic_error_1 = require("./classic_error");
22
23
  class ABAP {
23
24
  constructor() {
@@ -34,6 +35,7 @@ class ABAP {
34
35
  this.OffsetLength = offset_length_1.OffsetLength;
35
36
  this.templateFormatting = template_formatting_1.templateFormatting;
36
37
  this.expandIN = expand_in_1.expandIN;
38
+ this.expandDynamic = expand_dynamic_1.expandDynamic;
37
39
  this.ClassicError = classic_error_1.ClassicError;
38
40
  this.context = new context_1.Context();
39
41
  this.console = new console_1.Console();
@@ -36,11 +36,16 @@ class SelectDatabase {
36
36
  else if (target instanceof types_1.Table) {
37
37
  for (const row of rows) {
38
38
  const targetRow = (0, clone_1.clone)(target.getRowType());
39
- for (let columnName in row) {
40
- columnName = columnName.toLowerCase();
41
- // todo, non structured table = table with simple rows
42
- // @ts-ignore
43
- (_a = targetRow.get()[columnName]) === null || _a === void 0 ? void 0 : _a.set(row[columnName]);
39
+ if (targetRow instanceof types_1.Structure) {
40
+ for (let columnName in row) {
41
+ columnName = columnName.toLowerCase();
42
+ // @ts-ignore
43
+ (_a = targetRow.get()[columnName]) === null || _a === void 0 ? void 0 : _a.set(row[columnName]);
44
+ }
45
+ }
46
+ else {
47
+ const columnName = Object.keys(row)[0];
48
+ targetRow.set(row[columnName]);
44
49
  }
45
50
  // @ts-ignore
46
51
  abap.statements.insertInternal({ table: target, data: targetRow });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.4.5",
3
+ "version": "2.4.7",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",