@abaplint/runtime 2.3.48 → 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.
|
@@ -7,16 +7,17 @@ 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
|
-
|
|
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) || []) {
|
|
20
21
|
if (key.includes("-")) {
|
|
21
22
|
const [first, second] = key.split("-");
|
|
22
23
|
if ((0, compare_1.ne)(row[first.toLowerCase()].get()[second.toLowerCase()], insert[first.toLowerCase()].get()[second.toLowerCase()])) {
|
|
@@ -31,7 +32,7 @@ function insertInternal(options) {
|
|
|
31
32
|
}
|
|
32
33
|
return true;
|
|
33
34
|
};
|
|
34
|
-
if (tableOptions.isUnique === true) {
|
|
35
|
+
if (((_c = tableOptions.primaryKey) === null || _c === void 0 ? void 0 : _c.isUnique) === true) {
|
|
35
36
|
(0, read_table_1.readTable)(options.table, { withKey: compare });
|
|
36
37
|
// @ts-ignore
|
|
37
38
|
if (abap.builtin.sy.get().subrc.get() === 0) {
|
|
@@ -86,7 +87,7 @@ function insertInternal(options) {
|
|
|
86
87
|
abap.builtin.sy.get().subrc.set(0);
|
|
87
88
|
if (isSorted) {
|
|
88
89
|
// slow, but works for now
|
|
89
|
-
const by = (
|
|
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() }; });
|
|
90
91
|
(0, sort_1.sort)(options.table, { by: by });
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -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
|
|
18
|
+
export declare type ITableKey = {
|
|
19
|
+
name: string;
|
|
19
20
|
type?: TableAccessType;
|
|
20
|
-
keyFields
|
|
21
|
-
isUnique
|
|
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 {
|
package/build/src/types/table.js
CHANGED
|
@@ -32,9 +32,12 @@ class Table {
|
|
|
32
32
|
}
|
|
33
33
|
if (this.options === undefined) {
|
|
34
34
|
this.options = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
primaryKey: {
|
|
36
|
+
name: "primary_key",
|
|
37
|
+
type: TableAccessType.standard,
|
|
38
|
+
keyFields: [],
|
|
39
|
+
isUnique: false,
|
|
40
|
+
},
|
|
38
41
|
withHeader: false,
|
|
39
42
|
};
|
|
40
43
|
}
|