mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 16:13:58 +00:00
oracle function tests
This commit is contained in:
@@ -11,7 +11,7 @@ const {
|
|||||||
runCommandOnDriver,
|
runCommandOnDriver,
|
||||||
} = require('dbgate-tools');
|
} = 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) {
|
function flatSource(engineCond = x => !x.skipReferences) {
|
||||||
return _.flatten(
|
return _.flatten(
|
||||||
@@ -22,13 +22,14 @@ function flatSource(engineCond = x => !x.skipReferences) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function testDatabaseDiff(conn, driver, mangle, createObject = null) {
|
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,
|
conn,
|
||||||
`create table t2 (
|
driver,
|
||||||
id int not null primary key,
|
`create table ~t2 (
|
||||||
t1_id int null references t1(id)
|
~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))(
|
test.each(flatSource(x => x.supportRenameSqlObject))(
|
||||||
'Rename object - %s - %s',
|
'Rename object - %s - %s',
|
||||||
testWrapper(async (conn, driver, type, object, engine) => {
|
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);
|
await runCommandOnDriver(conn, driver, object.create1);
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ describe('Object analyse', () => {
|
|||||||
const structure2 = await driver.analyseIncremental(conn, structure1);
|
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||||
expect(structure2[type].length).toEqual(0);
|
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);
|
const structure3 = await driver.analyseIncremental(conn, structure2);
|
||||||
|
|
||||||
|
|||||||
@@ -427,20 +427,27 @@ end;$$`,
|
|||||||
drop1: 'DROP PROCEDURE ~obj1',
|
drop1: 'DROP PROCEDURE ~obj1',
|
||||||
drop2: 'DROP PROCEDURE ~obj2',
|
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 = [
|
const filterLocal = [
|
||||||
// filter local testing
|
// filter local testing
|
||||||
'-MySQL',
|
'MySQL',
|
||||||
'-MariaDB',
|
'-MariaDB',
|
||||||
'-PostgreSQL',
|
'-PostgreSQL',
|
||||||
'-SQL Server',
|
'-SQL Server',
|
||||||
'-SQLite',
|
'-SQLite',
|
||||||
'-CockroachDB',
|
'-CockroachDB',
|
||||||
'-ClickHouse',
|
'-ClickHouse',
|
||||||
'Oracle',
|
'-Oracle',
|
||||||
];
|
];
|
||||||
|
|
||||||
const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL');
|
const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL');
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ const driver = {
|
|||||||
sql = mtrim[1];
|
sql = mtrim[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('EXECUTE SQL:', sql);
|
|
||||||
const res = await dbhan.client.execute(sql);
|
const res = await dbhan.client.execute(sql);
|
||||||
try {
|
try {
|
||||||
const columns = extractOracleColumns(res.metaData);
|
const columns = extractOracleColumns(res.metaData);
|
||||||
|
|||||||
Reference in New Issue
Block a user