Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

LiveQuery doesn't work with Dates #113

Closed
rafaelmaroxa opened this issue May 22, 2017 · 0 comments · Fixed by #114
Closed

LiveQuery doesn't work with Dates #113

rafaelmaroxa opened this issue May 22, 2017 · 0 comments · Fixed by #114

Comments

@rafaelmaroxa
Copy link
Contributor

I have a query that looks like this:

NSDate *timeFilter = [NSDate dateWithTimeIntervalSinceNow:-(kMatchesNearMeTimeFilter)];

PFQuery *query = [PFQuery queryWithClassName:@"Match"];
[query whereKey:@"status" containedIn:@[kMatchStatusOpen, kMatchStatusInProgress]];
[query whereKey:@"location" nearGeoPoint:geopoint withinMiles:kMatchesNearMeDistance];
[query whereKey:@"updatedAt" greaterThanOrEqualTo:timeFilter];
[query includeKey:@"organizer"];
[query orderByDescending:@"updatedAt"];

When I try to subscribe to this query, the app crashes with an error very similar to the picture below (as seen on #97).

image

When Client serializes the ClientOperation to write it to the socket, JSONSerialization blows up because the Dictionary extension in QueryEncoder.swift fails to preemptively serialize any Dates that might be part of the query before it goes to JSONSerialization. I created a little playground that isolates the problem, and here's the error:

image

Possibly related issues: #16, #43, and #97.

rafaelmaroxa added a commit to rafaelmaroxa/ParseLiveQuery-iOS-OSX that referenced this issue May 22, 2017
Fix parse-community#113 by preemptively serializing Date objects before they are sent to JSONSerialization by the Client.
flovilmart pushed a commit that referenced this issue May 22, 2017
Fix #113 by preemptively serializing Date objects before they are sent to JSONSerialization by the Client.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant