Skip to content

fromJSON: Return date if value is a date #1293

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 6 commits into from
Feb 11, 2021

Conversation

dblythy
Copy link
Member

@dblythy dblythy commented Feb 10, 2021

Not sure how often this error would occur, but if you try to create a ParseObject with fromJSON with a Date, the date field is returned as {}

Related

Evidently, this bug also affects the localDataStore tests as:

descending date order should be larger (newer) to smaller (older)

Obj1: createdAt: new Date('2018-08-10T00:00:00.000Z'),
Obj2: createdAt: new Date('2018-08-11T00:00:00.000Z'),
Obj3: createdAt: new Date('2018-08-12T00:00:00.000Z'),

So, this test:

    q = new ParseQuery('Item');
    q.descending('_created_at');
    q.fromLocalDatastore();
    results = await q.find();

Should return Obj3, Obj2, Obj1. Instead, it returns Obj1, Obj2, then Obj3.

If this doesn't make sense, if you change the order that the objects are loaded here (e.g to Obj2, Obj3, Obj1), the tests will fail on the current master.

@dblythy dblythy changed the title Return date if value is a date fromJSON: Return date if value is a date Feb 10, 2021
@codecov
Copy link

codecov bot commented Feb 10, 2021

Codecov Report

Merging #1293 (9aa44a4) into master (c8270a7) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            master     #1293    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           58        59     +1     
  Lines         5650      5788   +138     
  Branches      1273      1299    +26     
==========================================
+ Hits          5650      5788   +138     
Impacted Files Coverage Δ
src/EventuallyQueue.js 100.00% <100.00%> (ø)
src/Parse.js 100.00% <100.00%> (ø)
src/ParseObject.js 100.00% <100.00%> (ø)
src/decode.js 100.00% <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 c8270a7...5229794. Read the comment docs.

@dplewis
Copy link
Member

dplewis commented Feb 10, 2021

Looks good, but the coverage decreased.

@dblythy
Copy link
Member Author

dblythy commented Feb 11, 2021

Should be good now @dplewis

@dplewis dplewis merged commit 3551a06 into parse-community:master Feb 11, 2021
@dblythy dblythy deleted the toJSON-date branch February 11, 2021 02:06
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