matchesQuery on relation query always finds zero objects
Environment Setup
parse-server 2.1.6, Heroku, MongoLab, iOS SDK 1.12.0
Steps to reproduce
var relationQuery = object.relation("relationKey").query();
var anotherQuery = new Parse.Query(Class);
anotherQuery.matchesQuery("key", relationQuery);
anotherQuery.find(); //Always finds 0 objects
This works correctly in hosted Parse. I also manually double-checked the db and can confirm this should find more than zero objects.
Logs/Trace
This error is showing up on the iOS side. May or may not be related:
[Error]: Response status code was unacceptable: 403 (Code: 1, Version: 1.12.0)
same problem here - parse server 2.1.6, we have an android app that uses below methods in query and previously works(with hosted parse) but at this time non of them works correctly:
whereMatchesQuery
whereMatchesKeyInQuery
whereDoesNotMatchQuery
whereDoesNotMatchKeyInQuery
@jgaull please see that gist does that reflect your failing cases?
Thanks @flovilmart! The only difference I can find is relationQuery.equalTo('even', true);. This can be found on lines 37 and 53. In my example the relation is used without adding any additional restrictions.
I will test today to see if adding a condition to my relation query makes it work.
@jgaull I added the restrictions to make sure I'd get the proper subset. Maybe the bug is when no parameters are passed. I'll try it also
@flovilmart I added relationQuery.equalTo("booleanProperty", true) and ensured that "booleanProperty" was set to true on every object in the relation. I got the same result: no objects found. Must be something else.
Thanks for the help! Let me know if you have an idea for something else to test.
uhm... Do you have ACL, class level permissions or anything else set? If you run the query as master, what does it do?
Does the object structure match what you have in the app in terms of relation, key etc...
Can you show me the schema as well?
ACL is default for _User object, public read and only the user has write. I am running the query as master using useMasterKey() in cloud code.
and the related objects are _Users ?
Correct
I really can't reproduce the error. Can you dump me the _SCHEMA collection from mongoDB?
TBH, I'm out of ideas now, are you running it in Cloud Code? Parse.Cloud.useMasterKey() don't work, you have to pass {useMasterKey: true} to your query.find(). Does it help?
Thanks @flovilmart! I tried {useMasterKey: true} and there was no change.
on which classes do you do your queries?
Sorry, definitely should have included that info.
I'm using the "members" relation in Group to query for UserWeeklyStats in one place and Rides in another. Both find zero objects.
Does the relation query itself returns some values? Can you try to split the query in 2? relationQuery first, get the objects and do a containedIn? ThatMs tough as I can't reproduce the issue at all...
I have tested splitting the query into two pieces. Both work independently as expected.
One thought I had was that, since this is my dev DB, some _Users have been deleted at various points during development. The relation probably still holds a reference to those deleted _Users. Is it possible that that's causing the query to break?
Tried deleting objects in the middle, and it behaves correctly, so the deletion doesn't seem to be the problem.
Can you set VERBOSE=1 on heroku (https://devcenter.heroku.com/articles/config-vars), and make a gist with the request logs ??
the interesting lines should be similar to:
GET /1/classes/AnOwner { 'user-agent': 'node-XMLHttpRequest, Parse/js1.7.1 (NodeJS 5.3.0)',
accept: '*/*',
'content-type': 'text/plain',
host: 'localhost:8378',
'content-length': '357',
connection: 'close' } {
"where": {
"key": {
"$inQuery": {
"where": {
"$relatedTo": {
"object": {
"__type": "Pointer",
"className": "AnotherOwner",
"objectId": "PBqgHRHCNd"
},
"key": "relationKey"
},
"even": true
},
"className": "AnObject"
}
}
},
"include": "key"
}
Does that look familiar? https://github.com/ParsePlatform/parse-server/issues/1036#issuecomment-196792097
Thanks @flovilmart! I imported using the Parse migration tool from the beginning so I don't think I'm experiencing the same issue.