@abaplint/runtime 2.3.49 → 2.3.51
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.
- package/build/src/statements/loop.js +19 -1
- package/package.json +1 -1
|
@@ -25,8 +25,12 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
|
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.loop = void 0;
|
|
28
|
+
const clone_1 = require("../clone");
|
|
28
29
|
const types_1 = require("../types");
|
|
30
|
+
// import {deleteInternal} from "./delete_internal";
|
|
31
|
+
const sort_1 = require("./sort");
|
|
29
32
|
function loop(table, options) {
|
|
33
|
+
var _a, _b;
|
|
30
34
|
return __asyncGenerator(this, arguments, function* loop_1() {
|
|
31
35
|
if (table === undefined) {
|
|
32
36
|
throw new Error("LOOP at undefined");
|
|
@@ -46,8 +50,22 @@ function loop(table, options) {
|
|
|
46
50
|
let loopTo = (options === null || options === void 0 ? void 0 : options.to) && options.to.get() < length ? options.to.get() : length;
|
|
47
51
|
const loopIndex = table.startLoop(loopFrom);
|
|
48
52
|
let entered = false;
|
|
53
|
+
let array = table.array();
|
|
54
|
+
if ((options === null || options === void 0 ? void 0 : options.usingKey) && options.usingKey !== undefined && options.usingKey !== "primary_key") {
|
|
55
|
+
const secondary = (_b = (_a = table.getOptions()) === null || _a === void 0 ? void 0 : _a.secondary) === null || _b === void 0 ? void 0 : _b.find(s => { var _a; return s.name.toUpperCase() === ((_a = options.usingKey) === null || _a === void 0 ? void 0 : _a.toUpperCase()); });
|
|
56
|
+
if (secondary === undefined) {
|
|
57
|
+
throw `LOOP, secondary key "${options.usingKey}" not found`;
|
|
58
|
+
}
|
|
59
|
+
const copy = (0, clone_1.clone)(table);
|
|
60
|
+
(0, sort_1.sort)(copy, { by: secondary.keyFields.map(k => { return { component: k.toLowerCase() }; }) });
|
|
61
|
+
/*
|
|
62
|
+
if (secondary?.isUnique === true) {
|
|
63
|
+
deleteInternal(copy, {adjacent: true, comparing: secondary.keyFields});
|
|
64
|
+
}
|
|
65
|
+
*/
|
|
66
|
+
array = copy.array();
|
|
67
|
+
}
|
|
49
68
|
try {
|
|
50
|
-
const array = table.array();
|
|
51
69
|
const isStructured = array[0] instanceof types_1.Structure;
|
|
52
70
|
while (loopIndex.index < loopTo) {
|
|
53
71
|
if (loopIndex.index > array.length) {
|