Skip to content

query include does not work as expected in conjunction with keys #2786

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
steven-supersolid opened this issue Sep 26, 2016 · 8 comments · Fixed by #2809
Closed

query include does not work as expected in conjunction with keys #2786

steven-supersolid opened this issue Sep 26, 2016 · 8 comments · Fixed by #2809
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Milestone

Comments

@steven-supersolid
Copy link
Contributor

steven-supersolid commented Sep 26, 2016

Issue Description

Queries that include a pointer and select that pointer do not retrieve the pointer attributes.

Steps to reproduce

Setup:

curl -X POST \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: restAPIKey" \
-H "Content-Type: application/json" \
-d '{"score":1337}' \
http://localhost:1337/parse/classes/GameScore

curl -X POST \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: restAPIKey" \
-H "Content-Type: application/json" \
-d '{"gameScore": { "__type": "Pointer", "className": "GameScore", "objectId": "GSdG0hSNgN"}, "other":"thing"}' \
http://localhost:1337/parse/classes/Player

Verify data created correctly, including the pointer:

curl -X GET \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: restAPIKey" \
--data-urlencode 'include=gameScore' \
http://localhost:1337/parse/classes/Player/gVKtQt2lDE

{"objectId":"gVKtQt2lDE","gameScore":{"objectId":"GSdG0hSNgN","score":1337,"createdAt":"2016-09-26T16:37:14.107Z","updatedAt":"2016-09-26T16:37:14.107Z","__type":"Object","className":"GameScore"},"other":"thing","createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z"}

Now also select the pointer (should omit other and include only gameScore), but properties of gameScore are also omitted:

curl -X GET \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: restAPIKey" \
--data-urlencode 'include=gameScore' \
--data-urlencode 'keys=gameScore' \
http://localhost:1337/parse/classes/Player/gVKtQt2lDE

{"objectId":"gVKtQt2lDE","gameScore":{"objectId":"GSdG0hSNgN","createdAt":"2016-09-26T16:37:14.107Z","updatedAt":"2016-09-26T16:37:14.107Z","__type":"Object","className":"GameScore"},"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z"}

Expected:
{"objectId":"gVKtQt2lDE","gameScore":{"objectId":"GSdG0hSNgN","score":1337,"createdAt":"2016-09-26T16:37:14.107Z","updatedAt":"2016-09-26T16:37:14.107Z","__type":"Object","className":"GameScore"},"createdAt":"2016-09-26T17:00:56.365Z","updatedAt":"2016-09-26T17:00:56.365Z"}

This may have been broken in #2737

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 2.2.22
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
@steven-supersolid
Copy link
Contributor Author

steven-supersolid commented Sep 26, 2016

I've checked against 2.2.21 and the bug was not present in that version

Looking at commits it was this one: 9c522be

@flovilmart
Copy link
Contributor

Probably related to the refactor of the way we handle key selection that is now native on the driver and not in code.

@flovilmart flovilmart added the type:bug Impaired feature or lacking behavior that is likely assumed label Sep 26, 2016
@flovilmart flovilmart added this to the 2.2.23 milestone Sep 26, 2016
@PogoRides-Admin
Copy link

Hey guys - curious how this got past core unit tests?! Seems like a pretty core feature to break during a patch level release.

Our staging servers on AWS use ~versioning and during a scheduled AWS config update a couple of nights ago, we got bumped to 2.2.22 which broke a well-tested simple query of the form:

q.include("user");
q.select(["user","otherKey"]);
q.find

Love to get all the incremental perf and security updates of the patches as long as backwards compatibility is maintained between major releases otherwise people have to use max versioning if core features can break during patch and minor releases.

Any way to bump the release timeline of 2.2.23 as this is a true regression bug and one could argue a pretty major one. Thanks.

@flovilmart
Copy link
Contributor

@kaveh-pogo feel free to provide a PR to patch it, as well as the according unit tests to prevent further regression. We have many tests covering those use cases, unfortunately, side effects happen and we can't possibly test every single possible query.

And I believe the version was indeed rightfully numbered, bugs happen.

@Meovel
Copy link

Meovel commented Oct 4, 2016

Hi @flovilmart , can you please take a look at #2795 , not sure if it is of the same issue as this one. Thanks!

@flovilmart
Copy link
Contributor

That's not the same issue, this issue is when using the keys through query.select("key") along side include to select only certain keys in the returned objects.

I believe your issue is when using the $select operator that does kind of a subquery on a certain key.

Is that right?

@Meovel
Copy link

Meovel commented Oct 4, 2016

@flovilmart Yes exactly

@steven-supersolid
Copy link
Contributor Author

Thanks Florent. I've tested the fix and also run against our integration tests to verify no new errors introduced for our use cases.

flovilmart added a commit that referenced this issue Oct 7, 2016
* Regression test for 2786

* Fix issue affecting selcting/including keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants