mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 12:46:00 +00:00
createSql test + postgre FIX
This commit is contained in:
2
.github/workflows/build-app-beta.yaml
vendored
2
.github/workflows/build-app-beta.yaml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Electron app
|
name: Electron app BETA
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|||||||
2
.github/workflows/build-docker-beta.yaml
vendored
2
.github/workflows/build-docker-beta.yaml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Docker image
|
name: Docker image BETA
|
||||||
|
|
||||||
# on: [push]
|
# on: [push]
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const obj1Match = expect.objectContaining({
|
|||||||
|
|
||||||
describe('Object analyse', () => {
|
describe('Object analyse', () => {
|
||||||
test.each(flatSource())(
|
test.each(flatSource())(
|
||||||
'Full analysis (%s - %s)',
|
'Full analysis - %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);
|
for (const sql of initSql) await driver.query(conn, sql);
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ describe('Object analyse', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
test.each(flatSource())(
|
test.each(flatSource())(
|
||||||
'Incremental analysis - add (%s - %s)',
|
'Incremental analysis - add - %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);
|
for (const sql of initSql) await driver.query(conn, sql);
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ describe('Object analyse', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
test.each(flatSource())(
|
test.each(flatSource())(
|
||||||
'Incremental analysis - drop (%s - %s)',
|
'Incremental analysis - drop - %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);
|
for (const sql of initSql) await driver.query(conn, sql);
|
||||||
|
|
||||||
@@ -58,4 +58,25 @@ describe('Object analyse', () => {
|
|||||||
expect(structure2[type][0]).toEqual(obj1Match);
|
expect(structure2[type][0]).toEqual(obj1Match);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test.each(flatSource())(
|
||||||
|
'Create SQL - add - %s - %s',
|
||||||
|
testWrapper(async (conn, driver, type, object, engine) => {
|
||||||
|
for (const sql of initSql) await driver.query(conn, sql);
|
||||||
|
|
||||||
|
await driver.query(conn, object.create1);
|
||||||
|
const structure1 = await driver.analyseFull(conn);
|
||||||
|
await driver.query(conn, object.drop1);
|
||||||
|
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||||
|
expect(structure2[type].length).toEqual(0);
|
||||||
|
|
||||||
|
await driver.query(conn, structure1[type][0].createSql);
|
||||||
|
|
||||||
|
const structure3 = await driver.analyseIncremental(conn, structure2);
|
||||||
|
|
||||||
|
expect(structure3[type].length).toEqual(1);
|
||||||
|
expect(structure3[type][0]).toEqual(obj1Match);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const t1Match = expect.objectContaining({
|
|||||||
|
|
||||||
describe('Table analyse', () => {
|
describe('Table analyse', () => {
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
test.each(engines.map(engine => [engine.label, engine]))(
|
||||||
'Table structure - full analysis (%s)',
|
'Table structure - full analysis - %s',
|
||||||
testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, engine) => {
|
||||||
await driver.query(conn, t1Sql);
|
await driver.query(conn, t1Sql);
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ describe('Table analyse', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
test.each(engines.map(engine => [engine.label, engine]))(
|
||||||
'Table add - incremental analysis (%s)',
|
'Table add - incremental analysis - %s',
|
||||||
testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, engine) => {
|
||||||
await driver.query(conn, 'CREATE TABLE t0 (id0 int)');
|
await driver.query(conn, 'CREATE TABLE t0 (id0 int)');
|
||||||
const structure1 = await driver.analyseFull(conn);
|
const structure1 = await driver.analyseFull(conn);
|
||||||
@@ -52,7 +52,7 @@ describe('Table analyse', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
test.each(engines.map(engine => [engine.label, engine]))(
|
||||||
'Table remove - incremental analysis (%s)',
|
'Table remove - incremental analysis - %s',
|
||||||
testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, engine) => {
|
||||||
await driver.query(conn, t1Sql);
|
await driver.query(conn, t1Sql);
|
||||||
await driver.query(conn, 'CREATE TABLE t2 (id2 int)');
|
await driver.query(conn, 'CREATE TABLE t2 (id2 int)');
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
objectId: `procedures:${proc.schema_name}.${proc.pure_name}`,
|
objectId: `procedures:${proc.schema_name}.${proc.pure_name}`,
|
||||||
pureName: proc.pure_name,
|
pureName: proc.pure_name,
|
||||||
schemaName: proc.schema_name,
|
schemaName: proc.schema_name,
|
||||||
|
createSql: `CREATE PROCEDURE "${proc.schema_name}"."${proc.pure_name}"() LANGUAGE ${proc.language}\nAS\n$$\n${proc.definition}\n$$`,
|
||||||
contentHash: proc.hash_code,
|
contentHash: proc.hash_code,
|
||||||
})),
|
})),
|
||||||
functions: routines.rows
|
functions: routines.rows
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ module.exports = `
|
|||||||
select
|
select
|
||||||
routine_name as "pure_name",
|
routine_name as "pure_name",
|
||||||
routine_schema as "schema_name",
|
routine_schema as "schema_name",
|
||||||
routine_definition as "create_sql",
|
routine_definition as "definition",
|
||||||
md5(routine_definition) as "hash_code",
|
md5(routine_definition) as "hash_code",
|
||||||
routine_type as "object_type"
|
routine_type as "object_type",
|
||||||
|
external_language as "language"
|
||||||
from
|
from
|
||||||
information_schema.routines where routine_schema != 'information_schema' and routine_schema != 'pg_catalog'
|
information_schema.routines where routine_schema != 'information_schema' and routine_schema != 'pg_catalog'
|
||||||
and (
|
and (
|
||||||
|
|||||||
Reference in New Issue
Block a user