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

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

Closed
leobortolotti opened this issue Feb 2, 2016 · 12 comments

Comments

@leobortolotti
Copy link

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?

@leobortolotti
Copy link
Author

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

@mkll
Copy link

mkll commented Feb 2, 2016

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.

@leobortolotti
Copy link
Author

See the answer of Héctor Ramos from Parse at this link:
https://parse.com/questions/query-where-the-elements-of-an-array-type-field-are-a-subset-of-a-given-array

@mkll
Copy link

mkll commented Feb 3, 2016

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

@leobortolotti
Copy link
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...

@edvincandon
Copy link

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.

@leobortolotti
Copy link
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!

@drew-gross
Copy link
Contributor

This has been fixed in #284

montymxb pushed a commit to montymxb/parse-server that referenced this issue Feb 14, 2016
…elation

Added param to getRelation for Issue 126
@alioguzhan
Copy link
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?

@0xthk
Copy link

0xthk commented May 20, 2016

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?

@richardgroves
Copy link

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.

@hackin247
Copy link

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

jeveloper added a commit to jeveloper/parse-server that referenced this issue May 6, 2017
Updated mongodb-core to 2.1.10
NODE-981 delegate auth to replset/mongos if inTopology is set.
NODE-978 Wrap connection.end in try/catch for node 0.10.x issue causing exceptions to be thrown, Also surfaced getConnection for mongos and replset.
Remove dynamic require (Issue parse-community#175, https://github.com/tellnes).
NODE-696 Handle interrupted error for createIndexes.
Fixed isse when user is executing find command using Server.command and it get interpreted as a wire protcol message, parse-community#172.
NODE-966 promoteValues not being promoted correctly to getMore.
Merged in fix for flushing out monitoring operations.
NODE-983 Add cursorId to aggregate and listCollections commands (Issue, parse-community#1510).
Mark group and profilingInfo as deprecated methods
NODE-956 DOCS Examples.
Update readable-stream to version 2.2.7.
NODE-978 Added test case to uncover connection.end issue for node 0.10.x.
NODE-972 Fix(db): don't remove database name if collectionName == dbName (Issue, parse-community#1502)
Fixed merging of writeConcerns on db.collection method.
NODE-970 mix in readPreference for strict mode listCollections callback.
NODE-966 added testcase for promoteValues being applied to getMore commands.
NODE-962 Merge in ignoreUndefined from collection level for find/findOne.
Remove multi option from updateMany tests/docs (Issue parse-community#1499, https://github.com/spratt).
NODE-963 Correctly handle cursor.count when using APM.
flovilmart pushed a commit that referenced this issue May 6, 2017
Updated mongodb-core to 2.1.10
NODE-981 delegate auth to replset/mongos if inTopology is set.
NODE-978 Wrap connection.end in try/catch for node 0.10.x issue causing exceptions to be thrown, Also surfaced getConnection for mongos and replset.
Remove dynamic require (Issue #175, https://github.com/tellnes).
NODE-696 Handle interrupted error for createIndexes.
Fixed isse when user is executing find command using Server.command and it get interpreted as a wire protcol message, #172.
NODE-966 promoteValues not being promoted correctly to getMore.
Merged in fix for flushing out monitoring operations.
NODE-983 Add cursorId to aggregate and listCollections commands (Issue, #1510).
Mark group and profilingInfo as deprecated methods
NODE-956 DOCS Examples.
Update readable-stream to version 2.2.7.
NODE-978 Added test case to uncover connection.end issue for node 0.10.x.
NODE-972 Fix(db): don't remove database name if collectionName == dbName (Issue, #1502)
Fixed merging of writeConcerns on db.collection method.
NODE-970 mix in readPreference for strict mode listCollections callback.
NODE-966 added testcase for promoteValues being applied to getMore commands.
NODE-962 Merge in ignoreUndefined from collection level for find/findOne.
Remove multi option from updateMany tests/docs (Issue #1499, https://github.com/spratt).
NODE-963 Correctly handle cursor.count when using APM.
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

8 participants