From fcaac322f21b3b0be8d3cfe6c273dbee4c762f38 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Fri, 28 May 2021 15:47:48 +0200 Subject: [PATCH] view columns test + try to fix --- .../__tests__/object-analyse.spec.js | 17 ++++++++++++----- integration-tests/engines.js | 2 +- .../src/backend/Analyser.js | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/integration-tests/__tests__/object-analyse.spec.js b/integration-tests/__tests__/object-analyse.spec.js index ef3d0dee..d1b2e259 100644 --- a/integration-tests/__tests__/object-analyse.spec.js +++ b/integration-tests/__tests__/object-analyse.spec.js @@ -13,6 +13,14 @@ function flatSource() { const obj1Match = expect.objectContaining({ pureName: 'obj1', }); +const view1Match = expect.objectContaining({ + pureName: 'obj1', + columns: [ + expect.objectContaining({ + columnName: 'id', + }), + ], +}); describe('Object analyse', () => { test.each(flatSource())( @@ -24,7 +32,7 @@ describe('Object analyse', () => { const structure = await driver.analyseFull(conn); expect(structure[type].length).toEqual(1); - expect(structure[type][0]).toEqual(obj1Match); + expect(structure[type][0]).toEqual(type == 'views' ? view1Match : obj1Match); }) ); @@ -39,7 +47,7 @@ describe('Object analyse', () => { const structure2 = await driver.analyseIncremental(conn, structure1); expect(structure2[type].length).toEqual(2); - expect(structure2[type].find(x => x.pureName == 'obj1')).toEqual(obj1Match); + expect(structure2[type].find(x => x.pureName == 'obj1')).toEqual(type == 'views' ? view1Match : obj1Match); }) ); @@ -55,7 +63,7 @@ describe('Object analyse', () => { const structure2 = await driver.analyseIncremental(conn, structure1); expect(structure2[type].length).toEqual(1); - expect(structure2[type][0]).toEqual(obj1Match); + expect(structure2[type][0]).toEqual(type == 'views' ? view1Match : obj1Match); }) ); @@ -75,8 +83,7 @@ describe('Object analyse', () => { const structure3 = await driver.analyseIncremental(conn, structure2); expect(structure3[type].length).toEqual(1); - expect(structure3[type][0]).toEqual(obj1Match); + expect(structure3[type][0]).toEqual(type == 'views' ? view1Match : obj1Match); }) ); - }); diff --git a/integration-tests/engines.js b/integration-tests/engines.js index 6c54ac20..6ffb168e 100644 --- a/integration-tests/engines.js +++ b/integration-tests/engines.js @@ -92,7 +92,7 @@ const engines = [ server: 'localhost', port: 15003, }, - // skipOnCI: true, + skipOnCI: true, objects: [views], }, ]; diff --git a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js index ae20f14a..33fb7e3c 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-postgres/src/backend/Analyser.js @@ -52,7 +52,7 @@ class Analyser extends DatabaseAnalyser { this.pool, this.createQuery(this.driver.dialect.stringAgg ? 'tableModifications' : 'tableList', ['tables']) ); - const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables'])); + const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables', 'views'])); const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables'])); const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables'])); const views = await this.driver.query(this.pool, this.createQuery('views', ['views']));