parse-community / parse-community/parse-server

Issue with Date for ParseLiveQueryClient callback

Open
#6,346 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

Issue Description

The ParseObject returned by LiveQuery events gives Date in String format, instead of Date format. Problem seem to specifically pertain to "Update" events. Strangely, some Date fields are returned in Date format while some are returned in String format.

I have tried several Parse-Server versions and with the exception of version 3.1.1, all other versions 3.7.2, 3.8.0, and 3.9.0 seem to have this problem.

P.S. I am aware that special fields like updatedAt and createdAt return String values. I was referring to custom Date fields created by me.

Note: I am using Back4App, which is a backend-as-a-service built on Parse.

Steps to reproduce

Codes in Android client

ParseQuery<ParseObject> liveQuery = ParseQuery.getQuery("QueueGP");
liveQuery.whereEqualTo("clinic", clinicId);

SubscriptionHandling<ParseObject> subscription = parseLiveQueryClient.subscribe(liveQuery);
subscription.handleEvents(new SubscriptionHandling.HandleEventsCallback<ParseObject>() {
    @Override
    public void onEvents(ParseQuery<ParseObject> query, SubscriptionHandling.Event event, ParseObject parseObject) {
        if(event == SubscriptionHandling.Event.UPDATE){
            Date registeredAt = parseObject.getDate("registeredAt");
        } ...
    }
});
Expected Results

onEvent from ParseLiveQueryClient (seen in verbose in my logs)

... Socket onMessage {"op":"update", ... "registeredAt":{"__type":"Date","iso":"2020-01-15T12:19:07.175Z"}}

Expected to see "Date" and "iso", and parseObject.getDate("registeredAt"); should contain date value

Actual Outcome

No "Date" or "iso" seen.

"registeredAt":"2020-01-15T12:19:19.759Z"

In actual, parseObject.getDate("registeredAt") gives null value, while parseObject.get("registeredAt"); gives value of String type

Environment Setup
  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : [3.72 / 3.8.0/ 3.9.0]
    • Operating System: [Handled by back4app]
    • Hardware: [Handled by back4app]
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): [Handled by back4app]
  • Database

    • MongoDB version: [Handled by back4app]
    • Storage engine: [Handled by back4app]
    • Hardware: [Handled by back4app]
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): [Handled by back4app]
Logs/Trace

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Android ParseLiveQueryClient UPDATE callback using the QueueGP query and the registeredAt field, comparing the onMessage payload with parseObject.getDate("registeredAt"). Trace the Parse Server LiveQuery update path to determine where the custom Date loses its __type and iso representation; done means custom Date fields remain dates and getDate returns the value.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.