Skip to content

Can't use a matchesKeyInQuery/doesNotMatchKeyInQuery where key == objectId and the queryKey is a pointer to the main query class #4346

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
JacobJT opened this issue Nov 13, 2017 · 3 comments

Comments

@JacobJT
Copy link

JacobJT commented Nov 13, 2017

Issue Description

I have a class, ClassA, that I'm trying to query for. I want to exclude all objects that exist as pointers on the results of a ClassB query. In my case, the classB query finds all objects where the requesting user is attached as the User pointer on the object as well. There is no way to use doesNotMatchKeyInQuery when the key I'm trying to match against is a pointer.

As a test to make sure you can use "objectId" as a key, I added a separate field and manually moved some of the objectIds of the ClassA objects to that field, and using that field as a string works fine. However, that would mean I'd need to duplicate data in order to perform this query. The only other solution I've found, which is far less efficient, is to perform the classBQuery, manually extract all the objectIds into an array, and use a notContainedIn query parameter on classAQuery, though this has bad scaling issues.

I think when queryKey in doesNotMatchKeyInQuery is a pointer, and key is a string, it should compare the objectId of the queryKey result instead of the full result.

Steps to reproduce

classAQuery = new Parse.Query("ClassA");
classBQuery = new Parse.Query("ClassB");
classBQuery.notEqualTo("User", request.user);
classAQuery.doesNotMatchKeyInQuery("objectId", "ClassA", classBQuery);

Since the "ClassA" key on ClassB objects is a pointer, no results match, thus non are excluded.

Expected Results

I want all objects that are not stored as pointers on the objects from the result of the ClassB query

Actual Outcome

No objects are excluded since a pointer doesn't match a string

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 2.6.5
    • Operating System: Standard using AWS parse-server setup
    • Hardware: Standard using AWS parse-server setup
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): local or AWS
@bohemima
Copy link
Contributor

Hi,

This should be fixed by #4308 but I'm unfortunately unable to fix the test for doesNotMatchKeyInQuery until I get home from my travels. Feel free to give it a stab if you have the time and knowledge.

@acinader
Copy link
Contributor

Hi @bohemima don't mind if I do! You did the hard part :). #4399

@Samigos
Copy link

Samigos commented Jun 18, 2018

Is it now fixed in both matchesKeyInQuery and doesNotMatchKeyInQuery?

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

4 participants