Fix "undefined property '__op'" in postgres update (#4541)

* Fix "undefined property '__op'" in postgres update

This causes a TypeError which becomes a regular Error,
before the update can be issued. (I think)

This happens when there is an object schema,
and there is also an unrelated field in originalUpdate
which is null or undefined.

e.g. when 'location' is a mandatory object in postgres,
and 'middleName' is an optional string,
PostgresStorageAdapter would throw when a query similar
to the below was performed:
(Object.keys(originalUpdate) would include "middleName" as a value of `k`)

    query.set('location', {'country': 'US'})
    query.set('middleName', undefined);

* Fix lint error
This commit is contained in:
Tyson Andre
2018-02-07 05:16:54 -08:00
committed by Florent Vilmart
parent db8594dd33
commit 83a0d7b685
2 changed files with 9 additions and 4 deletions

View File

@@ -268,7 +268,7 @@ export class UsersRouter extends ClassesRouter {
throw new Parse.Error(Parse.Error.EMAIL_NOT_FOUND, `No user found with email ${email}`);
}
const user = results[0];
// remove password field, messes with saving on postgres
delete user.password;