Skip to content

Query with $relatedTo has some critical issues #8532

@zanderisrael

Description

@zanderisrael

New Issue Checklist

Issue Description

Build a parse query that uses $relatedTo and count, in order to get results and total count.
Parse uses the "Limit" parameter value in order to limit the $relatedTo query, this causes a incorrect count value to be returned.

Steps to reproduce

await Parse.Query.fromJSON('ExampleClass',
{
    "limit":15,
    "skip:"0",
    "where": {
        "$relatedTo": {
            "object": {
                "__type": "Pointer",
                "className": "RelatedClass",
                "objectId": "someObjectId"
            },
            "key": "examples"
        },
    }
})

Actual Outcome

result = depends on order desc or asc, if valid document is in range (0-15) it will show, but if not it will not.
count = returns lower count than actual count of valid documents (14 when there are 33 for example)

Expected Outcome

result = should return all documents that match upto limit so paging can work properly.
count = should return total count of all matching documents, regardless of limit.

Environment

latest, 5.4.3

Server

  • Parse Server version: 5.4.3
  • Operating system: ubuntu
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): monogdb
  • Database version: 5.0
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): digitalocean

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): web
  • SDK version: rest

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions