Skip to content
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

Allow nested increment on undefined fields #1303

Merged
merged 2 commits into from
Feb 23, 2021
Merged

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Feb 23, 2021

Calling increment on a field that doesn't exists (serverData stored in object state) gets ignored.

const obj = new TestObject();
obj.increment('a.b.c.d'); // ignored
await obj.save();

I believe this was ignored because the server doesn't support it and throws the following error

Unhandled promise rejection: TypeError: Cannot read property 'split' of undefined

@codecov
Copy link

codecov bot commented Feb 23, 2021

Codecov Report

Merging #1303 (d83e8e8) into master (1abb841) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1303   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           60        60           
  Lines         5837      5832    -5     
  Branches      1312      1310    -2     
=========================================
- Hits          5837      5832    -5     
Impacted Files Coverage Δ
src/ParseObject.js 100.00% <ø> (ø)

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 1abb841...392d822. Read the comment docs.

@mtrezza
Copy link
Member

mtrezza commented Feb 23, 2021

What is the change? Is a new field with this PR incremented when saving?

@dplewis
Copy link
Member Author

dplewis commented Feb 23, 2021

The change is that we are allowing this request to go to the server. The server doesn't support this request yet.

I'll try to do a PR on the server side. I would like this merged to test it on the server side.

@mtrezza
Copy link
Member

mtrezza commented Feb 23, 2021

Do we have enough integration test in this repo to ensure letting this go to the server has no detrimental effects?

@dplewis
Copy link
Member Author

dplewis commented Feb 23, 2021

Technically the other SDK's don't prevent you from doing this. This also mean that a user can use the REST API and get the same results. Dot notation didn't exist in this SDK until I added it. #729

Since there is that unhandled promise rejection. We can't really test much.

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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.

2 participants