Skip to content

Commit 1550aad

Browse files
vitaly-tRafael Santos
authored and
Rafael Santos
committed
Update PostgresStorageAdapter.js (parse-community#2093)
If it really needs to reject with `undefined`, then this is the right way. Usually one just returns the result, let the caller provide the `.catch` ;) This way real errors can be swallowed, not very good ;)
1 parent f02ac7f commit 1550aad

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,9 @@ export class PostgresStorageAdapter {
220220
// this adapter doesn't know about the schema, return a promise that rejects with
221221
// undefined as the reason.
222222
getClass(className) {
223-
return this._client.query('SELECT * FROM "_SCHEMA" WHERE "className"=$<className>', { className })
224-
.then(result => {
225-
if (result.length === 1) {
226-
return result[0].schema;
227-
} else {
223+
return this._client.one('SELECT * FROM "_SCHEMA" WHERE "className"=$<className>', { className }, res=>res.schema)
224+
.catch(error => {
228225
throw undefined;
229-
}
230226
});
231227
}
232228

0 commit comments

Comments
 (0)