view columns test + try to fix

This commit is contained in:
Jan Prochazka 2021-05-28 15:47:48 +02:00
parent 5fa9a303cb
commit fcaac322f2
3 changed files with 14 additions and 7 deletions

View File

@ -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);
})
);
});

View File

@ -92,7 +92,7 @@ const engines = [
server: 'localhost',
port: 15003,
},
// skipOnCI: true,
skipOnCI: true,
objects: [views],
},
];

View File

@ -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']));