Skip to content

PFQuery's whereKey:equalTo: function seems not working on Parse Server like before #175

Description

@leobortolotti

Hi,
Inside Parse I have a key where I store an array of Pointers. Then I use the PFQuery's function whereKey:equalTo: like this:
[query whereKey:@"members" equalTo:[PFUser currentUser]];
The problem is that when it was Parse hosted, it was working well. But now with Parse Server it isn't working. It isn't retrieving the objects from Class that have [PFUser currentUser] inside the key's array.
Is it a bug in Parse Server?

Activity

  1. leobortolotti commented on Feb 2, 2016

    @leobortolotti
    Author

    The solution that I found is to use:
    [query whereKey:@"members" containsAllObjectsInArray:@[[PFUser currentUser]]];
    Works fine!!

  2. mkll commented on Feb 2, 2016

    @mkll

    The problem is that when it was Parse hosted, it was working well

    But it should not. Array of objects can't be equal to object.

  3. leobortolotti commented on Feb 3, 2016

    @leobortolotti
    Author
  4. mkll commented on Feb 3, 2016

    @mkll

    Ok, I was wrong, got it. But I can not call it good practice.

  5. leobortolotti commented on Feb 3, 2016

    @leobortolotti
    Author

    I agree with you. An array of objects can't be equal to object.
    It would be better with a new function for this case...

  6. edvincandon commented on Feb 3, 2016

    @edvincandon

    Hey @leobortolotti , this was reported as a bug as I noticed the same strange behaviour. #74
    I worked around this (for now), by storing only the object id's in the array.. You'll have to refactor some of your code, but works just fine with an array of id's.

  7. leobortolotti commented on Feb 3, 2016

    @leobortolotti
    Author

    @edvincandon Got it. As I said, I found this solution too:
    [query whereKey:@"members" containsAllObjectsInArray:@[[PFUser currentUser]]];
    But what you said is a good alternative too!! Thanks!

  8. drew-gross commented on Feb 11, 2016

    @drew-gross
    Contributor

    This has been fixed in #284

  9. added a commit that references this issue on Feb 14, 2016
  10. alioguzhan commented on Feb 16, 2016

    @alioguzhan
    Contributor

    hey, i have 2.0.8 installed but it seems still not fixed.

    this is my query:

    [query whereKey:@"bikers" equalTo:[PFUser currentUser]];

    this is how data stored in db:

    "bikers" : [ 
            {
                "__type" : "Pointer",
                "className" : "_User",
                "objectId" : "s6pjE71Hqk"
            }, 
            {
                "__type" : "Pointer",
                "className" : "_User",
                "objectId" : "27eJDbeT96"
            }
        ],
    

    but it works with:

    [query whereKey:@"bikers" containsAllObjectsInArray:@[[PFUser currentUser]]];

    did i miss something?

  11. 0xthk commented on May 20, 2016

    @0xthk

    Hi, @drew-gross

    Recently, I tried to migrate my app to parse-server and met this issue.

    My parse-server version is 2.2.10 which this issue should be fixed.

    I have a class called Room which has an array field members.

    I tried

    q.equalTo("members", PFUser.currentUser())

    returned nothing, but with

    q.whereKey("members", containsAllObjectsInArray:[PFUser.currentUser])

    it worked.

    I checked my _Scheme and it marked room.members as an array.

    Is there any idea why this issue still exist?

  12. richardgroves commented on Sep 30, 2016

    @richardgroves

    I'm seeing the same as @alioguzhan and @kenkuan. Am using a hosted Parse server of version 2.2.19, calling from iOS SDK v.1.14.2 (from cocoapods)

    and a query that worked against the original Parse service no longer works.

    Key 'userAck' has a value of [{"__type":"Pointer","className":"UserPublicData","objectId":"hkZD66uTV1"}]

    and before a query of:
    [query whereKey:@"userAck" equalTo:publicUser];
    where 'publicUser' is an object of type UserPublicData, worked fine.

    Now it gets 0 matches and I have to change it to
    [query whereKey:@"userAck" containsAllObjectsInArray:@[publicUser]];
    to get any results.

    And while the revised syntax does make more sense it means I've got an unknown about of broken queries throughout my code base, and previously documented behaviour has changed.

    The above reported fix #284 does not seem to have worked for several of us.

  13. hackin247 commented on Apr 17, 2017

    @hackin247

    Has this been resolved? I'm just now running into this issue via JS query.equalTo()

  14. added a commit that references this issue on May 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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