@abaplint/runtime 2.3.47 → 2.3.49

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.
@@ -36,6 +36,8 @@ function cp(left, right) {
36
36
  r = r.replace(/\)/g, "\\)");
37
37
  r = r.replace(/\./g, "\\.");
38
38
  r = r.replace(/\|/g, "\\|");
39
+ r = r.replace(/\$/g, "\\$");
40
+ r = r.replace(/\^/g, "\\^");
39
41
  r = r.replace(/#\*/g, "\\u{002A}");
40
42
  r = r.replace(/#\+/g, "\\u{002B}");
41
43
  r = r.replace(/\*/g, "[\\s\\S]*");
@@ -7,23 +7,32 @@ const types_1 = require("../types");
7
7
  const read_table_1 = require("./read_table");
8
8
  const sort_1 = require("./sort");
9
9
  function insertInternal(options) {
10
- var _a;
10
+ var _a, _b, _c, _d, _e;
11
11
  if (options.table instanceof types_1.FieldSymbol) {
12
12
  options.table = options.table.getPointer();
13
13
  }
14
14
  const tableOptions = options.table.getOptions();
15
- const isSorted = (tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.type) === types_1.TableAccessType.sorted || (tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.type) === types_1.TableAccessType.hashed;
15
+ const isSorted = ((_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.primaryKey) === null || _a === void 0 ? void 0 : _a.type) === types_1.TableAccessType.sorted || ((_b = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.primaryKey) === null || _b === void 0 ? void 0 : _b.type) === types_1.TableAccessType.hashed;
16
16
  if (isSorted) {
17
17
  const insert = options.data instanceof types_1.Structure ? options.data.get() : { table_line: options.data };
18
18
  const compare = (row) => {
19
- for (const key of (tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.keyFields) || []) {
20
- if ((0, compare_1.ne)(row[key.toLowerCase()], insert[key.toLowerCase()])) {
21
- return false;
19
+ var _a;
20
+ for (const key of ((_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.primaryKey) === null || _a === void 0 ? void 0 : _a.keyFields) || []) {
21
+ if (key.includes("-")) {
22
+ const [first, second] = key.split("-");
23
+ if ((0, compare_1.ne)(row[first.toLowerCase()].get()[second.toLowerCase()], insert[first.toLowerCase()].get()[second.toLowerCase()])) {
24
+ return false;
25
+ }
26
+ }
27
+ else {
28
+ if ((0, compare_1.ne)(row[key.toLowerCase()], insert[key.toLowerCase()])) {
29
+ return false;
30
+ }
22
31
  }
23
32
  }
24
33
  return true;
25
34
  };
26
- if (tableOptions.isUnique === true) {
35
+ if (((_c = tableOptions.primaryKey) === null || _c === void 0 ? void 0 : _c.isUnique) === true) {
27
36
  (0, read_table_1.readTable)(options.table, { withKey: compare });
28
37
  // @ts-ignore
29
38
  if (abap.builtin.sy.get().subrc.get() === 0) {
@@ -78,7 +87,7 @@ function insertInternal(options) {
78
87
  abap.builtin.sy.get().subrc.set(0);
79
88
  if (isSorted) {
80
89
  // slow, but works for now
81
- const by = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.keyFields) === null || _a === void 0 ? void 0 : _a.map(f => { return { component: f.toLowerCase() }; });
90
+ const by = (_e = (_d = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.primaryKey) === null || _d === void 0 ? void 0 : _d.keyFields) === null || _e === void 0 ? void 0 : _e.map(f => { return { component: f.toLowerCase() }; });
82
91
  (0, sort_1.sort)(options.table, { by: by });
83
92
  }
84
93
  }
@@ -1,6 +1,7 @@
1
1
  import { FieldSymbol, Integer, Table } from "../types";
2
2
  export interface ILoopOptions {
3
3
  where?: (i: any) => Promise<boolean>;
4
+ usingKey?: string;
4
5
  from?: Integer;
5
6
  to?: Integer;
6
7
  }
@@ -4,7 +4,7 @@ exports.readTable = void 0;
4
4
  const compare_1 = require("../compare");
5
5
  const types_1 = require("../types");
6
6
  function readTable(table, options) {
7
- var _a;
7
+ var _a, _b;
8
8
  let found = undefined;
9
9
  let foundIndex = 0;
10
10
  const arr = table.array();
@@ -34,7 +34,7 @@ function readTable(table, options) {
34
34
  }
35
35
  else if (options === null || options === void 0 ? void 0 : options.from) {
36
36
  if (table instanceof types_1.Table && options.from instanceof types_1.Structure) {
37
- const keys = (_a = table.getOptions()) === null || _a === void 0 ? void 0 : _a.keyFields;
37
+ const keys = (_b = (_a = table.getOptions()) === null || _a === void 0 ? void 0 : _a.primaryKey) === null || _b === void 0 ? void 0 : _b.keyFields;
38
38
  const isStructured = arr[0] instanceof types_1.Structure;
39
39
  if (keys !== undefined && isStructured === true) {
40
40
  // console.dir(keys);
@@ -15,11 +15,16 @@ export declare class LoopIndex {
15
15
  index: number;
16
16
  constructor(start: number);
17
17
  }
18
- export declare type ITableOptions = {
18
+ export declare type ITableKey = {
19
+ name: string;
19
20
  type?: TableAccessType;
20
- keyFields?: string[];
21
- isUnique?: boolean;
21
+ keyFields: string[];
22
+ isUnique: boolean;
23
+ };
24
+ export declare type ITableOptions = {
22
25
  withHeader: boolean;
26
+ primaryKey?: ITableKey;
27
+ secondary?: ITableKey[];
23
28
  };
24
29
  export declare type TableRowType = INumeric | Structure | ICharacter | Table | ABAPObject;
25
30
  export declare class Table {
@@ -32,9 +32,12 @@ class Table {
32
32
  }
33
33
  if (this.options === undefined) {
34
34
  this.options = {
35
- type: TableAccessType.standard,
36
- keyFields: [],
37
- isUnique: false,
35
+ primaryKey: {
36
+ name: "primary_key",
37
+ type: TableAccessType.standard,
38
+ keyFields: [],
39
+ isUnique: false,
40
+ },
38
41
  withHeader: false,
39
42
  };
40
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.3.47",
3
+ "version": "2.3.49",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",