MCPcopy Create free account
hub / github.com/abaplint/transpiler / runFilesPostgres

Function runFilesPostgres

test/_utils.ts:44–80  ·  view source on GitHub ↗
(abap: ABAP, files: IFile[])

Source from the content-addressed store, hash-verified

42 return "global.abap = abap;\n" + pre + res.objects[0].chunk.getCode();
43}
44
45export async function runFilesPostgres(abap: ABAP, files: IFile[]) {
46 const memory = files.map(f => new abaplint.MemoryFile(f.filename, f.contents));
47 const reg: abaplint.IRegistry = new abaplint.Registry().addFiles(memory);
48 const res = await new Transpiler().run(reg);
49 abap.console.clear();
50 if (res.databaseSetup.schemas.pg.length > 0) {
51 const dbName = "transpiler-" + crypto.randomBytes(10).toString("hex");
52 abap.context.databaseConnections["DEFAULT"] = new PostgresDatabaseClient({
53 user: "postgres",
54 host: "localhost",
55 database: "postgres",
56 password: "postgres",
57 port: 5432,
58 });
59 await abap.context.databaseConnections["DEFAULT"].connect();
60 await abap.context.databaseConnections["DEFAULT"].execute(`CREATE DATABASE "${dbName}";`);
61 await abap.context.databaseConnections["DEFAULT"].disconnect();
62
63 abap.context.databaseConnections["DEFAULT"] = new PostgresDatabaseClient({
64 user: "postgres",
65 host: "localhost",
66 database: dbName,
67 password: "postgres",
68 port: 5432,
69 });
70 await abap.context.databaseConnections["DEFAULT"].connect();
71 await abap.context.databaseConnections["DEFAULT"].execute(res.databaseSetup.schemas.pg);
72 await abap.context.databaseConnections["DEFAULT"].execute(res.databaseSetup.insert);
73 }
74 let pre = "";
75 for (const o of res.objects) {
76 if (o.object.type === "TABL") {
77 pre = o.chunk.getCode() + "\n";
78 }
79 }
80 return "global.abap = abap;\n" + pre + res.objects[0].chunk.getCode();
81}
82
83export async function runFilesHana(abap: ABAP, files: IFile[]) {

Callers 1

runAllDatabasesFunction · 0.90

Calls 7

toStringMethod · 0.80
getCodeMethod · 0.80
clearMethod · 0.65
connectMethod · 0.65
executeMethod · 0.65
disconnectMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected