Skip to content

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

Closed
@JacobJT

Description

@JacobJT

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions