@abaplint/runtime 2.5.42 → 2.5.44
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.
|
@@ -13,7 +13,6 @@ const compare_1 = require("../compare");
|
|
|
13
13
|
const loop_1 = require("./loop");
|
|
14
14
|
async function deleteInternal(target, options) {
|
|
15
15
|
var _a, e_1, _b, _c;
|
|
16
|
-
let prev = undefined;
|
|
17
16
|
let index = 0;
|
|
18
17
|
if (target instanceof types_1.FieldSymbol) {
|
|
19
18
|
target = target.getPointer();
|
|
@@ -48,6 +47,29 @@ async function deleteInternal(target, options) {
|
|
|
48
47
|
}
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
50
|
+
if ((options === null || options === void 0 ? void 0 : options.adjacent) === true) {
|
|
51
|
+
const array = target.array();
|
|
52
|
+
for (let index = array.length - 1; index > 0; index--) {
|
|
53
|
+
const prev = array[index - 1];
|
|
54
|
+
const i = array[index];
|
|
55
|
+
if (options === null || options === void 0 ? void 0 : options.comparing) {
|
|
56
|
+
let match = false;
|
|
57
|
+
for (const compareField of options.comparing) {
|
|
58
|
+
match = (0, compare_1.eq)(prev.get()[compareField], i.get()[compareField]);
|
|
59
|
+
if (!match) {
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (match) {
|
|
64
|
+
target.deleteIndex(index);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if ((0, compare_1.eq)(prev, i) === true) {
|
|
68
|
+
target.deleteIndex(index);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
51
73
|
try {
|
|
52
74
|
for (var _d = true, _e = __asyncValues((0, loop_1.loop)(target)), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
|
53
75
|
_c = _f.value;
|
|
@@ -62,23 +84,6 @@ async function deleteInternal(target, options) {
|
|
|
62
84
|
target.deleteIndex(index);
|
|
63
85
|
}
|
|
64
86
|
}
|
|
65
|
-
else if ((options === null || options === void 0 ? void 0 : options.adjacent) === true && prev !== undefined) {
|
|
66
|
-
if (options === null || options === void 0 ? void 0 : options.comparing) {
|
|
67
|
-
let match = false;
|
|
68
|
-
for (const compareField of options.comparing) {
|
|
69
|
-
match = (0, compare_1.eq)(prev.get()[compareField], i.get()[compareField]);
|
|
70
|
-
if (!match) {
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (match) {
|
|
75
|
-
target.deleteIndex(index);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if ((0, compare_1.eq)(prev, i) === true) {
|
|
79
|
-
target.deleteIndex(index);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
87
|
else if ((options === null || options === void 0 ? void 0 : options.index) && options.index.get() === index) {
|
|
83
88
|
target.deleteIndex(options.index.get() - 1);
|
|
84
89
|
}
|
|
@@ -88,7 +93,6 @@ async function deleteInternal(target, options) {
|
|
|
88
93
|
else if ((options === null || options === void 0 ? void 0 : options.from) && options.from.get() <= index + 1) {
|
|
89
94
|
target.deleteIndex(index);
|
|
90
95
|
}
|
|
91
|
-
prev = i;
|
|
92
96
|
}
|
|
93
97
|
finally {
|
|
94
98
|
_d = true;
|
|
@@ -87,7 +87,7 @@ export declare class Statements {
|
|
|
87
87
|
constructor(context: Context);
|
|
88
88
|
private _trace;
|
|
89
89
|
private _traceAsync;
|
|
90
|
-
_setTrace(): void;
|
|
90
|
+
_setTrace(min?: number): void;
|
|
91
91
|
deleteDatabase(table: string | ICharacter, options: IDeleteDatabaseOptions): Promise<void>;
|
|
92
92
|
insertDatabase(table: string | ICharacter, options: IInsertDatabaseOptions): Promise<number | undefined>;
|
|
93
93
|
message(options: IMessageOptions): Promise<void>;
|
|
@@ -88,27 +88,31 @@ class Statements {
|
|
|
88
88
|
this.translate = translate_1.translate;
|
|
89
89
|
this.context = context;
|
|
90
90
|
}
|
|
91
|
-
_trace(func, name) {
|
|
91
|
+
_trace(func, name, min) {
|
|
92
92
|
const exec = (...options) => {
|
|
93
93
|
const start = Date.now();
|
|
94
94
|
const result = func.bind(this)(...options);
|
|
95
|
-
const
|
|
96
|
-
|
|
95
|
+
const runtime = Date.now() - start;
|
|
96
|
+
if (runtime >= min) {
|
|
97
|
+
console.log(`STATEMENT: ${name}, ${runtime} ms`);
|
|
98
|
+
}
|
|
97
99
|
return result;
|
|
98
100
|
};
|
|
99
101
|
return exec;
|
|
100
102
|
}
|
|
101
|
-
_traceAsync(func, name) {
|
|
103
|
+
_traceAsync(func, name, min) {
|
|
102
104
|
const exec = async (...options) => {
|
|
103
105
|
const start = Date.now();
|
|
104
106
|
const result = await func.bind(this)(...options);
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
+
const runtime = Date.now() - start;
|
|
108
|
+
if (runtime >= min) {
|
|
109
|
+
console.log(`STATEMENT: ${name}, ${runtime} ms`);
|
|
110
|
+
}
|
|
107
111
|
return result;
|
|
108
112
|
};
|
|
109
113
|
return exec;
|
|
110
114
|
}
|
|
111
|
-
_setTrace() {
|
|
115
|
+
_setTrace(min = 10) {
|
|
112
116
|
const candidates = [...Object.keys(this), ...Object.getOwnPropertyNames(Statements.prototype)];
|
|
113
117
|
for (const c of candidates) {
|
|
114
118
|
if (c === "context" || c === "constructor" || c.startsWith("_") || c === "loop") {
|
|
@@ -116,10 +120,10 @@ class Statements {
|
|
|
116
120
|
}
|
|
117
121
|
const func = this[c];
|
|
118
122
|
if ((0, types_1.isAsyncFunction)(func)) {
|
|
119
|
-
this[c] = this._traceAsync(func, c);
|
|
123
|
+
this[c] = this._traceAsync(func, c, min);
|
|
120
124
|
}
|
|
121
125
|
else {
|
|
122
|
-
this[c] = this._trace(func, c);
|
|
126
|
+
this[c] = this._trace(func, c, min);
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
}
|
|
@@ -42,7 +42,17 @@ function insertInternal(options) {
|
|
|
42
42
|
return true;
|
|
43
43
|
};
|
|
44
44
|
if (((_c = tableOptions.primaryKey) === null || _c === void 0 ? void 0 : _c.isUnique) === true) {
|
|
45
|
-
|
|
45
|
+
const withKeyValue = [];
|
|
46
|
+
let binary = false;
|
|
47
|
+
const data = options === null || options === void 0 ? void 0 : options.data;
|
|
48
|
+
if (data instanceof types_1.Structure) {
|
|
49
|
+
const fieldName = tableOptions.primaryKey.keyFields[0].toLowerCase();
|
|
50
|
+
if (fieldName !== "table_line" && fieldName.includes("-") === false) {
|
|
51
|
+
withKeyValue.push({ key: (i) => { return i[fieldName]; }, value: data.get()[fieldName] });
|
|
52
|
+
binary = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
(0, read_table_1.readTable)(options.table, { withKey: compare, withKeyValue: withKeyValue, binarySearch: binary });
|
|
46
56
|
// @ts-ignore
|
|
47
57
|
if (abap.builtin.sy.get().subrc.get() === 0) {
|
|
48
58
|
// @ts-ignore
|
|
@@ -8,11 +8,11 @@ function compare(a, b, input) {
|
|
|
8
8
|
const descending = input.descending;
|
|
9
9
|
let vala = undefined;
|
|
10
10
|
let valb = undefined;
|
|
11
|
-
if (componentName
|
|
11
|
+
if (componentName === "table_line") {
|
|
12
12
|
vala = a.get();
|
|
13
13
|
valb = b.get();
|
|
14
14
|
}
|
|
15
|
-
else {
|
|
15
|
+
else if (componentName.includes("-")) {
|
|
16
16
|
const sub = componentName.split("-");
|
|
17
17
|
vala = a;
|
|
18
18
|
valb = b;
|
|
@@ -21,18 +21,22 @@ function compare(a, b, input) {
|
|
|
21
21
|
valb = valb.get()[s];
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
else {
|
|
25
|
+
vala = a.get()[componentName];
|
|
26
|
+
valb = b.get()[componentName];
|
|
27
|
+
}
|
|
24
28
|
if (vala === undefined || valb === undefined) {
|
|
25
29
|
throw new Error("sort compare, wrong component name, " + componentName);
|
|
26
30
|
}
|
|
27
|
-
if ((0, compare_1.
|
|
28
|
-
return 0;
|
|
29
|
-
}
|
|
30
|
-
else if (descending && (0, compare_1.gt)(vala, valb)) {
|
|
31
|
+
if (descending && (0, compare_1.gt)(vala, valb)) {
|
|
31
32
|
return -1;
|
|
32
33
|
}
|
|
33
34
|
else if (!descending && (0, compare_1.lt)(vala, valb)) {
|
|
34
35
|
return -1;
|
|
35
36
|
}
|
|
37
|
+
else if ((0, compare_1.eq)(vala, valb)) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
36
40
|
else {
|
|
37
41
|
return 1;
|
|
38
42
|
}
|