Skip to content

select() with a nested key results in an empty object when a pointer doesn't exist #4080

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

Closed
pgiguere1 opened this issue Aug 4, 2017 · 2 comments

Comments

@pgiguere1
Copy link

Issue Description

When using select() with a nested key on a pointer, e.g. select("pointerKey.nestedKey")
and the fetched object doesn't have a pointer set, getting the pointer will result in and empty object rather than undefined.

I am experiencing this issue on Heroku, but am not able the reproduce it locally, using the same parse-server and node versions.

Steps to reproduce

var query = new Parse.Query("MyClass");
query.doesNotExist("pointerKey");
query.include("pointerKey");
query.first({
  success: function(myObject) {
  	var pointerObject = myObject.get("pointerKey");
  	console.log(pointerObject); // undefined

  	// Expected behavior
  }
});
var query = new Parse.Query("MyClass");
query.doesNotExist("pointerKey");
query.include("pointerKey");
query.select("pointerKey.nestedKey"); // This line causes the issue
query.first({
  success: function(myObject) {
  	var pointerObject = myObject.get("pointerKey");
  	console.log(pointerObject); // [object Object]
  	console.log(JSON.stringify(pointerObject)); // "{}"

  	// pointerObject should be undefined but is an empty Object
  }
});

Expected Results

A pointer that has not been set should return undefined when using get().

Actual Outcome

An empty object is returned when using get().

Environment Setup

  • Server

    • parse-server version: 2.5.3
    • Operating System: Ubuntu 14.04
    • Hardware: Heroku hobby dyno
    • Localhost or remote server? Remote, Heroku
  • Database

    • MongoDB version: 3.0.11
    • Storage engine: MMAPv1
    • Hardware: Shared cluster (AWS 1GB RAM)
    • Localhost or remote server? Remote, mLab
@pgiguere1 pgiguere1 changed the title select() with nested keys result in empty object when a pointer doesn't exist select() with a nested key results in an empty object when a pointer doesn't exist Aug 4, 2017
@promisenxu
Copy link
Contributor

Duplicate of #3999

@flovilmart
Copy link
Contributor

Closing as duplicate, will be fixed with next release.

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

No branches or pull requests

3 participants