diff --git a/integration-tests/__tests__/db-import.spec.js b/integration-tests/__tests__/db-import.spec.js index e972a15e..752f25e1 100644 --- a/integration-tests/__tests__/db-import.spec.js +++ b/integration-tests/__tests__/db-import.spec.js @@ -40,4 +40,36 @@ describe('DB Import', () => { 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'); + }) + ); + }); diff --git a/integration-tests/engines.js b/integration-tests/engines.js index b11d40cb..ed1bcaf0 100644 --- a/integration-tests/engines.js +++ b/integration-tests/engines.js @@ -116,11 +116,11 @@ const engines = [ const filterLocal = [ // filter local testing - 'MySQL', - 'PostgreSQL', - 'SQL Server', + '-MySQL', + '-PostgreSQL', + '-SQL Server', 'SQLite', - 'CockroachDB', + '-CockroachDB', ]; module.exports = process.env.CITEST diff --git a/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js b/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js index 8e9ab36c..6192328c 100644 --- a/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js @@ -20,6 +20,11 @@ class Analyser extends DatabaseAnalyser { super(pool, driver, version); } + async _computeSingleObjectId() { + const { pureName } = this.singleObjectFilter; + this.singleObjectId = pureName; + } + async _getFastSnapshot() { 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); @@ -48,7 +53,13 @@ class Analyser extends DatabaseAnalyser { } 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 views = objects.rows.filter((x) => x.type == 'view'); // console.log('TABLES', tables);