mssql indexes analyse WIP

This commit is contained in:
Jan Prochazka
2021-08-14 09:36:22 +02:00
parent 71e1ea5736
commit 3c0bc69662
5 changed files with 42 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ const engines = require('../engines');
const { testWrapper } = require('../tools');
const t1Sql = 'CREATE TABLE t1 (id int not null primary key, val1 varchar(50) null)';
const ix1Sql = 'CREATE index ix1 ON t1(val1)';
const t2Sql = 'CREATE TABLE t2 (id int not null primary key, val2 varchar(50) null)';
const txMatch = (tname, vcolname, nextcol) =>
@@ -98,7 +99,7 @@ describe('Table analyse', () => {
const structure1 = await driver.analyseFull(conn);
if (engine.dbSnapshotBySeconds) await new Promise(resolve => setTimeout(resolve, 1100));
await driver.query(conn, 'ALTER TABLE t2 ADD nextcol varchar(50)');
const structure2 = await driver.analyseIncremental(conn, structure1);
@@ -109,4 +110,16 @@ describe('Table analyse', () => {
expect(structure2.tables.find(x => x.pureName == 't2')).toEqual(t2NextColMatch);
})
);
test.each(engines.map(engine => [engine.label, engine]))(
'Index - full analysis - %s',
testWrapper(async (conn, driver, engine) => {
await driver.query(conn, t1Sql);
await driver.query(conn, ix1Sql);
const structure = await driver.analyseFull(conn);
const t1 = structure.tables.find(x => x.pureName == 't1');
expect(t1.indexes.length).toEqual(1);
})
);
});