Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2018
Merged

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

merged 2 commits into from
Feb 7, 2018

Conversation

TysonAndre
Copy link
Contributor

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);

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);
@codecov
Copy link

codecov bot commented Feb 2, 2018

Codecov Report

Merging #4541 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4541      +/-   ##
==========================================
- Coverage   92.89%   92.88%   -0.02%     
==========================================
  Files         118      118              
  Lines        8448     8450       +2     
==========================================
+ Hits         7848     7849       +1     
- Misses        600      601       +1
Impacted Files Coverage Δ
src/Routers/UsersRouter.js 93.38% <ø> (ø) ⬆️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 97.12% <100%> (-0.1%) ⬇️
src/RestWrite.js 93.46% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db8594d...37b9944. Read the comment docs.

@flovilmart flovilmart merged commit 83a0d7b into parse-community:master Feb 7, 2018
UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this pull request Mar 21, 2020
)

* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants