Skip to content

Commit 324cd85

Browse files
vitaly-tdrew-gross
authored andcommitted
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).
1 parent 5518edc commit 324cd85

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class PostgresStorageAdapter {
2222
.catch(error => {
2323
if (error.code === PostgresDuplicateRelationError) {
2424
// Table already exists, must have been created by a different request. Ignore error.
25-
return;
2625
} else {
2726
throw error;
2827
}
@@ -77,7 +76,7 @@ export class PostgresStorageAdapter {
7776
return this._client.query('SELECT "className" FROM "_SCHEMA"')
7877
.then(results => {
7978
const classes = ['_SCHEMA', ...results.map(result => result.className)];
80-
return Promise.all(classes.map(className => this._client.query('DROP TABLE $<className:name>', { className })));
79+
return this._client.task(t=>t.batch(classes.map(className=>t.none('DROP TABLE $<className:name>', { className }))));
8180
}, error => {
8281
if (error.code === PostgresRelationDoesNotExistError) {
8382
// No _SCHEMA collection. Don't delete anything.

0 commit comments

Comments
 (0)