Skip to content

$select with query not work #2795

Closed
Closed

Description

@Meovel

Issue Description

Queries that contain a $select query on pointer fields always return empty result - unable to handle inner $select query.

Steps to reproduce

Setup
There is a user, a quiz belonging to the user and some game records of that quiz:
User:

curl -X GET \
-H "X-Parse-Application-Id: appid"  \
-H "X-Parse-REST-API-Key: restkey"  \
128.00.00.00:1337/classes/_User/ggz9FqKTFI
{"objectId":"ggz9FqKTFI","username":"Test",
"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z"}

Quiz - owner points to above user:

curl -X GET \
-H "X-Parse-Application-Id: appid"  \
-H "X-Parse-REST-API-Key: restkey"  \
--data-urlencode 'include=owner'  \
128.00.00.00:1337/classes/Quiz/GSdG0hSNgN
{"objectId":"GSdG0hSNgN","name":"testQuiz",
"owner":{"objectId":"ggz9FqKTFI","username":"Test",
"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z",
"__type":"Object","className":"_User"}
"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z"}

Game record - of above quiz:

curl -X GET \
-H "X-Parse-Application-Id: appid"  \
-H "X-Parse-REST-API-Key: restkey"  \
--data-urlencode 'include=quiz'  \
128.00.00.00:1337/classes/Game/gVKtQt2lDE
{"objectId":"gVKtQt2lDE","score":95,
"quiz":{"objectId":"GSdG0hSNgN","name":"testQuiz",
"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z",
"__type":"Object","className":"Quiz"}
"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z"}

Problem
Below query is to retrieve play records of quizzes belonging to a certain user,

curl -X GET \
-H "X-Parse-Application-Id: appid"  \
-H "X-Parse-REST-API-Key: restkey"  \
-G --data-urlencode \
'where={"quizling":{"$select":
{"query":{"className":"Quiz",
"where":{"owner {"__type":"Pointer","className":"_User","objectId":"ggz9FqKTFI"}}},
"key":"objectId"}}}' \
128.00.00.00:1337/classes/Game/

The inner query $select gets the object ids of all quizzes of a user and then out query grabs all game records points to any of the ids.

The parse sever returns:

{"results":[]}

The same query returns expected result on parse.com:

{"results":
[{"objectId":"gVKtQt2lDE","score":95,
"quiz":{"objectId":"GSdG0hSNgN",
"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z",
"__type":"Object","className":"Quiz"}
"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z"}]}

Same query works fine on parse.com, all queries like this with $select on a pointer field will return empty on parse-server.

I think it is supposed to be supported in #2737 , if not please consider it for future release, thanks.

Environment Setup

  • Server
    • parse-server version: 2.2.22
    • Localhost or remote #server: Remote server on AWS

Activity

  1. changed the title [-]$select on pointer fields not work as expected[/-] [+]$select with query not work[/+] on Oct 4, 2016
  2. flovilmart commented on Sep 10, 2017

    @flovilmart
    Contributor

    I believe this issue has been fixed since, can you update to latest version and reopen if necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionSupport or code-level question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions