@abaplint/runtime 2.5.41 → 2.5.43
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.
|
@@ -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
|
-
|
|
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
|
}
|