parse-community / parse-community/parse-server

Saving an Undefined value to a ParseObject Field that is undefined already, creates a null pointer field in MongoDb Atlas Document which creates query issues

Open
#8,639 2 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

New Issue Checklist
Issue Description

Saving an undefined value into an existing ParseObject field, creates a null pointer in the mongoDb Atlas document.
For Example:
I have a ParseObject "Form" with a field "student" which is a _User object.
When I set "undefined" into the student field and then save the Form object it creates a null pointer field which is not detectable through the parse-server but appears as null in mongoDB as such -> _p_student null

The moment this pointer is created with null value, it is impossible to use doesNotExist and exists in a query because it believes the object exists. While in the parse dashboard it appears as undefined, but acts as an existing object when working with exists & doesNotExist in a query.

Steps to reproduce

Easy, just save an undefined value into an object field of an existing ParseObject and save the object. It will seem as if the value is undefined, but don't be fooled. the dashboard even will show you that it's undefined and when using .get('student') it witll be undefined in code. BUT, when you want to do "exists" in a query it will assume it exists, because when going to mongodb atlas you will find a _p_field_name : null and thus disrupting the exists/doesNotExists functionality in a query.

Actual Outcome

var formQuery = new Parse.Query('Form');
formQuery.doesNotExist('student');
formQuery.find({ useMasterKey: true })
.then(function (formObjects) {
//The object where I've inserted an undefined value into student will not return in this query
})

Expected Outcome

var formQuery = new Parse.Query('Form');
formQuery.doesNotExist('student');
formQuery.find({ useMasterKey: true })
.then(function (formObjects) {
//Having the object which I saved undefined into student should still appear here
})

Environment

NodeJs

Server

  • Parse Server version: 6.2.0
  • Operating system: NodeJs
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Heroku

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 6.0
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): MongoDB Atlas

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): JavaScript
  • SDK version: 6.2.0
    "parse": "4.0.1",
    "parse-server": "^6.2.0",

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 save using a ParseObject field and the Parse.Query doesNotExist('student') example, then inspect the corresponding MongoDB Atlas document for the _p_student value. Trace the Parse Server persistence path for undefined fields and verify that saving undefined preserves doesNotExist query behavior without creating a null field.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.