diff --git a/src/common/customizations/firebird.ts b/src/common/customizations/firebird.ts index 77e8fba7..ab0aff38 100644 --- a/src/common/customizations/firebird.ts +++ b/src/common/customizations/firebird.ts @@ -37,7 +37,7 @@ export const customizations: Customizations = { // Structure schemas: false, tables: true, - views: false, + views: true, triggers: true, routines: false, functions: false, diff --git a/src/common/customizations/mysql.ts b/src/common/customizations/mysql.ts index 619b1e7f..c3bfa830 100644 --- a/src/common/customizations/mysql.ts +++ b/src/common/customizations/mysql.ts @@ -65,7 +65,6 @@ export const customizations: Customizations = { unsigned: true, nullable: true, zerofill: true, - tableOptions: true, autoIncrement: true, comment: true, collation: true, diff --git a/src/main/ipc-handlers/schema.ts b/src/main/ipc-handlers/schema.ts index af5bc379..5ea6e2db 100644 --- a/src/main/ipc-handlers/schema.ts +++ b/src/main/ipc-handlers/schema.ts @@ -97,7 +97,7 @@ export default (connections: {[key: string]: antares.Client}) => { ipcMain.handle('get-engines', async (event, uid) => { try { - const result: any = await connections[uid].getEngines(); + const result: unknown = await connections[uid].getEngines(); return { status: 'success', response: result }; } diff --git a/src/main/libs/clients/FirebirdSQLClient.ts b/src/main/libs/clients/FirebirdSQLClient.ts index 05e04606..b5c2b31f 100644 --- a/src/main/libs/clients/FirebirdSQLClient.ts +++ b/src/main/libs/clients/FirebirdSQLClient.ts @@ -9,7 +9,7 @@ export class FirebirdSQLClient extends AntaresCore { private _schema?: string; private _runningConnections: Map; private _connectionsToCommit: Map; - protected _connection?: firebird.Database; + protected _connection?: firebird.Database | firebird.ConnectionPool; _params: firebird.Options; private _types: {[key: number]: string} ={ @@ -92,7 +92,7 @@ export class FirebirdSQLClient extends AntaresCore { if (!this._poolSize) this._connection = await this.getConnection(); else - this._connection = await this.getConnectionPool(); + this._connection = this.getConnectionPool(); } async getConnection () { @@ -104,18 +104,21 @@ export class FirebirdSQLClient extends AntaresCore { }); } - async getConnectionPool () { + getConnectionPool () { const pool = firebird.pool(this._poolSize, { ...this._params, blobAsText: true }); - return new Promise((resolve, reject) => { - pool.get((err, db) => { - if (err) reject(err); - else resolve(db); - }); - }); + // return new Promise((resolve, reject) => { + // pool.get((err, db) => { + // if (err) reject(err); + // else resolve(db); + // }); + // }); + + return pool; } destroy () { - return this._connection.detach(); + if (this._poolSize) + return (this._connection as firebird.ConnectionPool).destroy(); } use (): void { @@ -162,7 +165,14 @@ export class FirebirdSQLClient extends AntaresCore { AND RDB$RELATION_TYPE = 0 `); - tablesArr.push(...tables); + const { rows: views } = await this.raw>(` + SELECT + DISTINCT RDB$VIEW_NAME AS name, + 'view' AS type + FROM RDB$VIEW_RELATIONS + `); + + tablesArr.push(...tables, ...views); const { rows: triggers } = await this.raw>(` SELECT @@ -821,12 +831,14 @@ export class FirebirdSQLClient extends AntaresCore { : [sql]; let connection: firebird.Database | firebird.Transaction; + const isPool = this._poolSize; if (!args.autocommit && args.tabUid) { // autocommit OFF if (this._connectionsToCommit.has(args.tabUid)) connection = this._connectionsToCommit.get(args.tabUid); else { connection = await this.getConnection(); + const transaction = await new Promise((resolve, reject) => { (connection as firebird.Database).transaction(firebird.ISOLATION_READ_COMMITED, (err, transaction) => { if (err) reject(err); @@ -837,8 +849,19 @@ export class FirebirdSQLClient extends AntaresCore { this._connectionsToCommit.set(args.tabUid, transaction); } } - else// autocommit ON - connection = this._connection; + else { // autocommit ON + if (isPool) { + const pool = this._connection as firebird.ConnectionPool; + connection = await new Promise((resolve, reject) => { + pool.get((err, db) => { + if (err) reject(err); + else resolve(db); + }); + }); + } + else + connection = this._connection as firebird.Database; + } for (const query of queries) { if (!query) continue; @@ -993,6 +1016,8 @@ export class FirebirdSQLClient extends AntaresCore { resultsArr.push({ rows, report, fields, keys, duration }); } + (connection as firebird.Database).detach(); + const result = resultsArr.length === 1 ? resultsArr[0] : resultsArr; return result as unknown as T;