From b4aca8afc9dc9acc07302725c60ed9c97173669f Mon Sep 17 00:00:00 2001 From: Vitaly Tomilov Date: Wed, 27 Dec 2017 20:44:11 +0000 Subject: [PATCH] Reuse connection in getAllClasses (#4463) as per the title. --- src/Adapters/Storage/Postgres/PostgresStorageAdapter.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index 231d1a6c..bfe0d624 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -856,8 +856,11 @@ export class PostgresStorageAdapter { // schemas cannot be retrieved, returns a promise that rejects. Requirements for the // rejection reason are TBD. getAllClasses() { - return this._ensureSchemaCollectionExists() - .then(() => this._client.map('SELECT * FROM "_SCHEMA"', null, row => toParseSchema({ className: row.className, ...row.schema }))); + const self = this; + return this._client.task('get-all-classes', function * (t) { + yield self._ensureSchemaCollectionExists(t); + return yield t.map('SELECT * FROM "_SCHEMA"', null, row => toParseSchema({ className: row.className, ...row.schema })); + }); } // Return a promise for the schema with the given name, in Parse format. If