oracle function tests

This commit is contained in:
Jan Prochazka
2024-12-13 14:34:53 +01:00
parent c0fcd681be
commit a203480a72
4 changed files with 18 additions and 11 deletions

View File

@@ -11,7 +11,7 @@ const {
runCommandOnDriver,
} = require('dbgate-tools');
const initSql = ['CREATE TABLE t1 (id int primary key)', 'CREATE TABLE t2 (id int primary key)'];
const initSql = ['CREATE TABLE ~t1 (~id int primary key)', 'CREATE TABLE ~t2 (~id int primary key)'];
function flatSource(engineCond = x => !x.skipReferences) {
return _.flatten(
@@ -22,13 +22,14 @@ function flatSource(engineCond = x => !x.skipReferences) {
}
async function testDatabaseDiff(conn, driver, mangle, createObject = null) {
await driver.query(conn, `create table t1 (id int not null primary key)`);
await runCommandOnDriver(conn, driver, `create table ~t1 (~id int not null primary key)`);
await driver.query(
await runCommandOnDriver(
conn,
`create table t2 (
id int not null primary key,
t1_id int null references t1(id)
driver,
`create table ~t2 (
~id int not null primary key,
~t1_id int null references ~t1(~id)
)`
);
@@ -78,7 +79,7 @@ describe('Alter database', () => {
test.each(flatSource(x => x.supportRenameSqlObject))(
'Rename object - %s - %s',
testWrapper(async (conn, driver, type, object, engine) => {
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
for (const sql of initSql) await runCommandOnDriver(conn, driver, sql);
await runCommandOnDriver(conn, driver, object.create1);

View File

@@ -87,7 +87,7 @@ describe('Object analyse', () => {
const structure2 = await driver.analyseIncremental(conn, structure1);
expect(structure2[type].length).toEqual(0);
await runCommandOnDriver(conn, driver, structure1[type][0].createSql);
await driver.script(conn, structure1[type][0].createSql);
const structure3 = await driver.analyseIncremental(conn, structure2);

View File

@@ -427,20 +427,27 @@ end;$$`,
drop1: 'DROP PROCEDURE ~obj1',
drop2: 'DROP PROCEDURE ~obj2',
},
{
type: 'functions',
create1: 'CREATE FUNCTION ~obj1 RETURN NUMBER IS v_count NUMBER; \n BEGIN SELECT COUNT(*) INTO v_count FROM ~t1;\n RETURN v_count;\n END ~obj1',
create2: 'CREATE FUNCTION ~obj2 RETURN NUMBER IS v_count NUMBER; \n BEGIN SELECT COUNT(*) INTO v_count FROM ~t2;\n RETURN v_count;\n END ~obj2',
drop1: 'DROP FUNCTION ~obj1',
drop2: 'DROP FUNCTION ~obj2',
},
],
},
];
const filterLocal = [
// filter local testing
'-MySQL',
'MySQL',
'-MariaDB',
'-PostgreSQL',
'-SQL Server',
'-SQLite',
'-CockroachDB',
'-ClickHouse',
'Oracle',
'-Oracle',
];
const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL');

View File

@@ -107,7 +107,6 @@ const driver = {
sql = mtrim[1];
}
// console.log('EXECUTE SQL:', sql);
const res = await dbhan.client.execute(sql);
try {
const columns = extractOracleColumns(res.metaData);