From 324cd85775a97ce02f8746f5e3d00a10c107780b Mon Sep 17 00:00:00 2001 From: Vitaly Tomilov Date: Mon, 13 Jun 2016 01:27:02 +0100 Subject: [PATCH] Update PostgresStorageAdapter.js (#2045) 1. removing `return` where it does nothing; 2. changing repeated queries to be executed as a task. See [Chaining Queries](https://github.com/vitaly-t/pg-promise/wiki/chaining-queries). --- src/Adapters/Storage/Postgres/PostgresStorageAdapter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index ce0f2dd5..62f0703b 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -22,7 +22,6 @@ export class PostgresStorageAdapter { .catch(error => { if (error.code === PostgresDuplicateRelationError) { // Table already exists, must have been created by a different request. Ignore error. - return; } else { throw error; } @@ -77,7 +76,7 @@ export class PostgresStorageAdapter { return this._client.query('SELECT "className" FROM "_SCHEMA"') .then(results => { const classes = ['_SCHEMA', ...results.map(result => result.className)]; - return Promise.all(classes.map(className => this._client.query('DROP TABLE $', { className }))); + return this._client.task(t=>t.batch(classes.map(className=>t.none('DROP TABLE $', { className })))); }, error => { if (error.code === PostgresRelationDoesNotExistError) { // No _SCHEMA collection. Don't delete anything.