Skip to content
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

Queries on array values broken since 2.3.1 #516

Open
3 of 4 tasks
eskil-booli opened this issue May 29, 2023 · 3 comments
Open
3 of 4 tasks

Queries on array values broken since 2.3.1 #516

eskil-booli opened this issue May 29, 2023 · 3 comments
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug

Comments

@eskil-booli
Copy link

New Issue Checklist

We're not running the latest Parse server version, hence I haven't checked the last item above.

Issue Description

The fix for equalTo in 2.3.1 broke queries on array values.

Steps to reproduce

For example, to fetch all roles for a specific user:

$query = ParseUser::query();
$parseUser = $query->get("someUserId", true);
$query = ParseRole::query();
$query->equalTo("users", $parseUser);
$parseRoles = $query->find(true);

Actual Outcome

In previous versions, the query sent to Parse would look like:

{
  "users": {
    "__type": "Pointer",
    "className": "_User",
    "objectId": "someUserId"
  }
}

Which would give us the roles for that user back.

Expected Outcome

In 2.3.1 the query became:

{
  "where": {
    "users": {
      "$eq": {
        "__type": "Pointer",
        "className": "_User",
        "objectId":"someUserId"
      }
    }
  }
}

Which does not give any roles back. users on _Role is an array with a single user in our case.

Environment

Parse PHP SDK

  • SDK version: 2.3.2
  • PHP version: 8.2.6

Server

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

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 3.6
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): AWS
@parse-github-assistant
Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@zeliard91
Copy link
Contributor

Hi,

For information, the same bug is also affecting queries on Relations when trying to fetch records from the inversed side of the relationship with a recent version of the server.

// suppose we have a author object, for which we want to get all books
$author = ...

// first we will create a query on the Book object
$query = new ParseQuery("Book");

// now we will query the authors relation to see if the author object we have
// is contained therein
$query->equalTo("authors", $author);

The SDK is sending a "where authors $eq: {}" instead of "authors: {}"

Environment

Parse PHP SDK

  • SDK version: 2.3.2
  • PHP version: 8.1.18

Server

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

Database

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

zeliard91 added a commit to zeliard91/DoctrineParseBundle that referenced this issue May 30, 2023
@mtrezza mtrezza added the bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) label May 30, 2023
@dplewis
Copy link
Member

dplewis commented Jun 17, 2023

We could revert #510 back. Can you write a failing test? We might have to do a server fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug
Projects
None yet
Development

No branches or pull requests

4 participants