fixed sqlitesingle object analyse + test

This commit is contained in:
Jan Prochazka 2021-11-11 08:25:23 +01:00
parent 6baeb58500
commit e0aeae5220
3 changed files with 48 additions and 5 deletions

View File

@ -40,4 +40,36 @@ describe('DB Import', () => {
expect(res.rows[0].cnt.toString()).toEqual('6'); expect(res.rows[0].cnt.toString()).toEqual('6');
}) })
); );
test.each(engines.map(engine => [engine.label, engine]))(
'Import two tables - %s',
testWrapper(async (conn, driver, engine) => {
// const reader = await fakeObjectReader({ delay: 10 });
// const reader = await fakeObjectReader();
const reader1 = createImportStream();
const writer1 = await tableWriter({
systemConnection: conn,
driver,
pureName: 't1',
createIfNotExists: true,
});
await copyStream(reader1, writer1);
const reader2 = createImportStream();
const writer2 = await tableWriter({
systemConnection: conn,
driver,
pureName: 't2',
createIfNotExists: true,
});
await copyStream(reader2, writer2);
const res1 = await driver.query(conn, `select count(*) as cnt from t1`);
expect(res1.rows[0].cnt.toString()).toEqual('6');
const res2 = await driver.query(conn, `select count(*) as cnt from t2`);
expect(res2.rows[0].cnt.toString()).toEqual('6');
})
);
}); });

View File

@ -116,11 +116,11 @@ const engines = [
const filterLocal = [ const filterLocal = [
// filter local testing // filter local testing
'MySQL', '-MySQL',
'PostgreSQL', '-PostgreSQL',
'SQL Server', '-SQL Server',
'SQLite', 'SQLite',
'CockroachDB', '-CockroachDB',
]; ];
module.exports = process.env.CITEST module.exports = process.env.CITEST

View File

@ -20,6 +20,11 @@ class Analyser extends DatabaseAnalyser {
super(pool, driver, version); super(pool, driver, version);
} }
async _computeSingleObjectId() {
const { pureName } = this.singleObjectFilter;
this.singleObjectId = pureName;
}
async _getFastSnapshot() { async _getFastSnapshot() {
const objects = await this.driver.query(this.pool, "select * from sqlite_master where type='table' or type='view'"); const objects = await this.driver.query(this.pool, "select * from sqlite_master where type='table' or type='view'");
const indexcols = await this.driver.query(this.pool, indexcolsQuery); const indexcols = await this.driver.query(this.pool, indexcolsQuery);
@ -48,7 +53,13 @@ class Analyser extends DatabaseAnalyser {
} }
async _runAnalysis() { async _runAnalysis() {
const objects = await this.driver.query(this.pool, "select * from sqlite_master where type='table' or type='view'"); const objects = await this.driver.query(
this.pool,
super.createQuery(
"select * from sqlite_master where (type='table' or type='view') and name =OBJECT_ID_CONDITION",
['tables', 'views']
)
);
const tables = objects.rows.filter((x) => x.type == 'table'); const tables = objects.rows.filter((x) => x.type == 'table');
const views = objects.rows.filter((x) => x.type == 'view'); const views = objects.rows.filter((x) => x.type == 'view');
// console.log('TABLES', tables); // console.log('TABLES', tables);