@abaplint/runtime 1.8.2 → 1.8.6
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/compare/eq.js +23 -3
- package/build/src/statements/delete_database.d.ts +7 -0
- package/build/src/statements/delete_database.js +44 -0
- package/build/src/statements/index.d.ts +2 -0
- package/build/src/statements/index.js +2 -0
- package/build/src/statements/insert_internal.js +7 -5
- package/package.json +1 -1
package/build/src/compare/eq.js
CHANGED
|
@@ -2,16 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.eq = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function compareTables(left, right) {
|
|
6
|
+
const leftArray = left.array();
|
|
7
|
+
const rightArray = right.array();
|
|
8
|
+
if (leftArray.length !== rightArray.length) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
for (let i = 0; i < leftArray.length; i++) {
|
|
12
|
+
const rowCompare = eq(leftArray[i], rightArray[i]);
|
|
13
|
+
if (rowCompare === false) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
8
16
|
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
function eq(left, right) {
|
|
9
20
|
if (right instanceof types_1.FieldSymbol) {
|
|
10
21
|
return eq(left, right.getPointer());
|
|
11
22
|
}
|
|
12
23
|
else if (left instanceof types_1.FieldSymbol) {
|
|
13
24
|
return eq(left.getPointer(), right);
|
|
14
25
|
}
|
|
26
|
+
if (left instanceof types_1.Table || right instanceof types_1.Table) {
|
|
27
|
+
if (left instanceof types_1.Table && right instanceof types_1.Table) {
|
|
28
|
+
return compareTables(left, right);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// this happens in dynamic/ANY typed scenarios?
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
15
35
|
if (left instanceof types_1.Structure || right instanceof types_1.Structure) {
|
|
16
36
|
if (!(right instanceof types_1.Structure)) {
|
|
17
37
|
return false;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FieldSymbol, Structure, Table } from "../types";
|
|
2
|
+
import { ICharacter } from "../types/_character";
|
|
3
|
+
export interface IInsertDatabaseOptions {
|
|
4
|
+
from?: Structure | FieldSymbol;
|
|
5
|
+
table?: Table | FieldSymbol;
|
|
6
|
+
}
|
|
7
|
+
export declare function deleteDatabase(table: string | ICharacter, options: IInsertDatabaseOptions): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteDatabase = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
function deleteDatabase(table, options) {
|
|
6
|
+
if (this.db === undefined) {
|
|
7
|
+
throw new Error("Runtime, database not initialized");
|
|
8
|
+
}
|
|
9
|
+
if (options.table instanceof types_1.FieldSymbol) {
|
|
10
|
+
options.table = options.table.getPointer();
|
|
11
|
+
}
|
|
12
|
+
if (options.from instanceof types_1.FieldSymbol) {
|
|
13
|
+
options.from = options.from.getPointer();
|
|
14
|
+
}
|
|
15
|
+
if (options.table) {
|
|
16
|
+
for (const row of options.table.array()) {
|
|
17
|
+
deleteDatabase.bind(this)(table, { from: row });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (options.from) {
|
|
21
|
+
const where = [];
|
|
22
|
+
const structure = options.from.get();
|
|
23
|
+
for (const k of Object.keys(structure)) {
|
|
24
|
+
// todo, integers should not be surrounded by '"'?
|
|
25
|
+
const str = k + ' = "' + structure[k].get() + '"';
|
|
26
|
+
where.push(str);
|
|
27
|
+
}
|
|
28
|
+
const sql = `DELETE FROM ${table} WHERE ${where.join(" AND ")}`;
|
|
29
|
+
let subrc = 0;
|
|
30
|
+
try {
|
|
31
|
+
this.db.exec(sql);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
subrc = 4;
|
|
35
|
+
}
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
abap.builtin.sy.get().subrc.set(subrc);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw "deleteDatabase todo";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.deleteDatabase = deleteDatabase;
|
|
44
|
+
//# sourceMappingURL=delete_database.js.map
|
|
@@ -17,6 +17,7 @@ import { getRunTime } from "./get_run_time";
|
|
|
17
17
|
import { getTime } from "./get_time";
|
|
18
18
|
import { insertDatabase } from "./insert_database";
|
|
19
19
|
import { insertInternal } from "./insert_internal";
|
|
20
|
+
import { deleteDatabase } from "./delete_database";
|
|
20
21
|
import { loop } from "./loop";
|
|
21
22
|
import { message } from "./message";
|
|
22
23
|
import { modifyDatabase } from "./modify_database";
|
|
@@ -49,6 +50,7 @@ export declare class Statements {
|
|
|
49
50
|
getBit: typeof getBit;
|
|
50
51
|
callFunction: typeof callFunction;
|
|
51
52
|
getRunTime: typeof getRunTime;
|
|
53
|
+
deleteDatabase: typeof deleteDatabase;
|
|
52
54
|
getTime: typeof getTime;
|
|
53
55
|
insertDatabase: typeof insertDatabase;
|
|
54
56
|
insertInternal: typeof insertInternal;
|
|
@@ -19,6 +19,7 @@ const get_run_time_1 = require("./get_run_time");
|
|
|
19
19
|
const get_time_1 = require("./get_time");
|
|
20
20
|
const insert_database_1 = require("./insert_database");
|
|
21
21
|
const insert_internal_1 = require("./insert_internal");
|
|
22
|
+
const delete_database_1 = require("./delete_database");
|
|
22
23
|
const loop_1 = require("./loop");
|
|
23
24
|
const message_1 = require("./message");
|
|
24
25
|
const modify_database_1 = require("./modify_database");
|
|
@@ -54,6 +55,7 @@ class Statements {
|
|
|
54
55
|
this.getBit = get_bit_1.getBit;
|
|
55
56
|
this.callFunction = call_function_1.callFunction;
|
|
56
57
|
this.getRunTime = get_run_time_1.getRunTime;
|
|
58
|
+
this.deleteDatabase = delete_database_1.deleteDatabase;
|
|
57
59
|
this.getTime = get_time_1.getTime;
|
|
58
60
|
this.insertDatabase = insert_database_1.insertDatabase;
|
|
59
61
|
this.insertInternal = insert_internal_1.insertInternal;
|
|
@@ -23,12 +23,14 @@ function insertInternal(options) {
|
|
|
23
23
|
}
|
|
24
24
|
return true;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (abap.builtin.sy.get().subrc.get() === 0) {
|
|
26
|
+
if (tableOptions.isUnique === true) {
|
|
27
|
+
(0, read_table_1.readTable)(options.table, { withKey: compare });
|
|
29
28
|
// @ts-ignore
|
|
30
|
-
abap.builtin.sy.get().subrc.
|
|
31
|
-
|
|
29
|
+
if (abap.builtin.sy.get().subrc.get() === 0) {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
abap.builtin.sy.get().subrc.set(4);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
let data = options.data;
|