From ff9184701df231944114a7bac3babda530f811bc Mon Sep 17 00:00:00 2001 From: Vitaly Tomilov Date: Sat, 27 May 2017 19:08:08 +0100 Subject: [PATCH 1/2] Update PostgresStorageAdapter.js refactoring `deleteClass`. --- .../Storage/Postgres/PostgresStorageAdapter.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index a01ce25b31..173b80238c 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -563,15 +563,13 @@ export class PostgresStorageAdapter { // Drops a collection. Resolves with true if it was a Parse Schema (eg. _User, Custom, etc.) // and resolves with false if it wasn't (eg. a join table). Rejects if deletion was impossible. - deleteClass(className) { - return Promise.resolve().then(() => { - const operations = [[`DROP TABLE IF EXISTS $1:name`, [className]], - [`DELETE FROM "_SCHEMA" WHERE "className"=$1`, [className]]]; - return this._client.tx(t=>t.batch(operations.map(statement=>t.none(statement[0], statement[1])))); - }).then(() => { - // resolves with false when _Join table - return className.indexOf('_Join:') != 0; - }); + function deleteClass(className) { + const operations = [ + {query: `DROP TABLE IF EXISTS $1:name`, values: [className]}, + {query: `DELETE FROM "_SCHEMA" WHERE "className" = $1`, values: [className]} + ]; + return this._client.tx(t => t.none(this._pgp.helpers.concat(operations))) + .then(() => className.indexOf('_Join:') != 0); // resolves with false when _Join table } // Delete all data known to this adapter. Used for testing. From a875536bed3a4139c4aa60ed559b8373082002c7 Mon Sep 17 00:00:00 2001 From: Vitaly Tomilov Date: Sat, 27 May 2017 19:12:18 +0100 Subject: [PATCH 2/2] Update PostgresStorageAdapter.js --- src/Adapters/Storage/Postgres/PostgresStorageAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index 173b80238c..6af602fc94 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -563,7 +563,7 @@ export class PostgresStorageAdapter { // Drops a collection. Resolves with true if it was a Parse Schema (eg. _User, Custom, etc.) // and resolves with false if it wasn't (eg. a join table). Rejects if deletion was impossible. - function deleteClass(className) { + deleteClass(className) { const operations = [ {query: `DROP TABLE IF EXISTS $1:name`, values: [className]}, {query: `DELETE FROM "_SCHEMA" WHERE "className" = $1`, values: [className]}