Skip to content

Commit

Permalink
fix(PostgreSQL): schema different than public not automatically selec…
Browse files Browse the repository at this point in the history
…ted, closes #172
  • Loading branch information
Fabio286 committed Jan 17, 2022
1 parent f28531a commit 46b45c8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/libs/clients/PostgreSQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,23 @@ export class PostgreSQLClient extends AntaresCore {
}

/**
* Executes an "USE" query
* Executes an 'SET search_path TO "${schema}"' query
*
* @param {String} schema
* @param {Object?} connection optional
* @memberof PostgreSQLClient
*/
use (schema) {
use (schema, connection) {
this._schema = schema;
if (schema)
return this.raw(`SET search_path TO "${schema}"`);

if (schema) {
const sql = `SET search_path TO "${schema}"`;

if (connection === undefined)
return this.raw(sql);
else
return connection.query(sql);
}
}

/**
Expand Down Expand Up @@ -1441,7 +1449,7 @@ export class PostgreSQLClient extends AntaresCore {
this._runningConnections.set(args.tabUid, connection.processID);

if (args.schema && args.schema !== 'public')
await this.use(args.schema);
await this.use(args.schema, connection);

for (const query of queries) {
if (!query) continue;
Expand Down

0 comments on commit 46b45c8

Please sign in to comment.