@abaplint/transpiler 2.1.26 → 2.1.29
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/db/index.js
CHANGED
|
@@ -12,26 +12,27 @@ class DatabaseSetup {
|
|
|
12
12
|
return {
|
|
13
13
|
schemas: {
|
|
14
14
|
sqlite: new sqlite_database_schema_1.SQLiteDatabaseSchema(this.reg).run(),
|
|
15
|
-
hdb: "todo",
|
|
16
|
-
pg: "todo",
|
|
15
|
+
hdb: ["todo"],
|
|
16
|
+
pg: ["todo"],
|
|
17
17
|
},
|
|
18
18
|
insert: this.buildInsert(),
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
////////////////////
|
|
22
22
|
buildInsert() {
|
|
23
|
-
|
|
23
|
+
// note: avoid hitting maximum statement size by splitting into multiple statements
|
|
24
|
+
const insert = [];
|
|
24
25
|
// INSERT data
|
|
25
26
|
for (const obj of this.reg.getObjects()) {
|
|
26
27
|
if (obj instanceof abaplint.Objects.MessageClass) {
|
|
27
|
-
insert
|
|
28
|
+
insert.push(this.insertT100(obj));
|
|
28
29
|
}
|
|
29
30
|
else if (obj instanceof abaplint.Objects.Class
|
|
30
31
|
|| obj instanceof abaplint.Objects.Interface) {
|
|
31
|
-
insert
|
|
32
|
+
insert.push(this.insertREPOSRC(obj));
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
insert
|
|
35
|
+
insert.push(this.insertT000());
|
|
35
36
|
return insert;
|
|
36
37
|
}
|
|
37
38
|
insertREPOSRC(obj) {
|
|
@@ -44,7 +45,7 @@ class DatabaseSetup {
|
|
|
44
45
|
if (raw === undefined) {
|
|
45
46
|
return "";
|
|
46
47
|
}
|
|
47
|
-
return `INSERT INTO reposrc ('PROGNAME', 'DATA') VALUES ('${name}', '${this.escape(raw)}')
|
|
48
|
+
return `INSERT INTO reposrc ('PROGNAME', 'DATA') VALUES ('${name}', '${this.escape(raw)}');`;
|
|
48
49
|
}
|
|
49
50
|
insertT000() {
|
|
50
51
|
const tabl = this.reg.getObject("TABL", "T000");
|
|
@@ -54,7 +55,7 @@ class DatabaseSetup {
|
|
|
54
55
|
const type = tabl.parseType(this.reg);
|
|
55
56
|
if (type instanceof abaplint.BasicTypes.StructureType && type.getComponents().length >= 3) {
|
|
56
57
|
// todo, this should take the client number from the settings
|
|
57
|
-
return `INSERT INTO t000 ('MANDT', 'CCCATEGORY', 'CCNOCLIIND') VALUES ('123', '', '')
|
|
58
|
+
return `INSERT INTO t000 ('MANDT', 'CCCATEGORY', 'CCNOCLIIND') VALUES ('123', '', '');`;
|
|
58
59
|
}
|
|
59
60
|
else {
|
|
60
61
|
return "";
|
|
@@ -67,12 +68,16 @@ class DatabaseSetup {
|
|
|
67
68
|
}
|
|
68
69
|
let ret = "";
|
|
69
70
|
for (const m of msag.getMessages()) {
|
|
70
|
-
ret += `INSERT INTO t100 ('SPRSL', 'ARBGB', 'MSGNR', 'TEXT') VALUES ('E', '${msag.getName()}', '${m.getNumber()}', '${this.escape(m.getMessage())}')
|
|
71
|
+
ret += `INSERT INTO t100 ('SPRSL', 'ARBGB', 'MSGNR', 'TEXT') VALUES ('E', '${msag.getName()}', '${m.getNumber()}', '${this.escape(m.getMessage())}');`;
|
|
71
72
|
}
|
|
72
73
|
return ret;
|
|
73
74
|
}
|
|
74
75
|
escape(value) {
|
|
75
|
-
|
|
76
|
+
let ret = value.replace(/\'/g, "''");
|
|
77
|
+
// statements are inside a javascript string stemplate
|
|
78
|
+
ret = ret.replace(/\\/g, "\\\\");
|
|
79
|
+
ret = ret.replace(/`/g, "\\`");
|
|
80
|
+
return ret;
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
exports.DatabaseSetup = DatabaseSetup;
|
|
@@ -7,14 +7,15 @@ class SQLiteDatabaseSchema {
|
|
|
7
7
|
this.reg = reg;
|
|
8
8
|
}
|
|
9
9
|
run() {
|
|
10
|
-
|
|
10
|
+
const statements = [];
|
|
11
11
|
// CREATE TABLEs
|
|
12
12
|
for (const obj of this.reg.getObjects()) {
|
|
13
|
-
if (obj instanceof abaplint.Objects.Table
|
|
14
|
-
|
|
13
|
+
if (obj instanceof abaplint.Objects.Table
|
|
14
|
+
&& obj.getTableCategory() === abaplint.Objects.TableCategory.Transparent) {
|
|
15
|
+
statements.push(this.transparentTable(obj).trim());
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
return
|
|
18
|
+
return statements;
|
|
18
19
|
}
|
|
19
20
|
//////////////////
|
|
20
21
|
transparentTable(tabl) {
|
package/build/src/unit_test.js
CHANGED
|
@@ -19,11 +19,17 @@ globalThis.abap = new runtime.ABAP();\n`;
|
|
|
19
19
|
ret += `${this.buildImports(reg, useImport)}
|
|
20
20
|
|
|
21
21
|
export async function initializeABAP() {\n`;
|
|
22
|
-
ret += ` const sqlite =
|
|
22
|
+
ret += ` const sqlite = [];\n`;
|
|
23
|
+
for (const i of dbSetup.schemas.sqlite) {
|
|
24
|
+
ret += `sqlite.push(\`${i}\`);\n`;
|
|
25
|
+
}
|
|
23
26
|
ret += ` const hdb = \`${dbSetup.schemas.hdb}\`;\n`;
|
|
24
27
|
ret += ` const pg = \`${dbSetup.schemas.pg}\`;\n`;
|
|
25
28
|
ret += ` const schemas = {sqlite, hdb, pg};\n`;
|
|
26
|
-
ret += ` const insert =
|
|
29
|
+
ret += ` const insert = [];\n`;
|
|
30
|
+
for (const i of dbSetup.insert) {
|
|
31
|
+
ret += `insert.push(\`${i}\`);\n`;
|
|
32
|
+
}
|
|
27
33
|
if (extraSetup === undefined) {
|
|
28
34
|
ret += `// no setup logic specified in config\n`;
|
|
29
35
|
}
|