Using includeKey: on array of pointers results in error
For implementation related questions or technical support, please refer to the Stack Overflow and Server Fault communities.
Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!
- [x] You've met the prerequisites.
- [x] You're running the latest version of Parse Server.
- [x] You've searched through existing issues. Chances are that your issue has been reported or resolved before.
Environment Setup
Local
Xcode 7.3 iPhone 6s simulator with iOS 9.3 Parse-iOS-SDK 1.13
Remote
heroku/nodejs parse-server 2.2.4 parse 1.8.1
Steps to reproduce
Precondition: There exists an object on the database that has an array of pointers as one of its fields.
- Create a
PFQueryon the object's type. - Try to include the array of pointers field using
includeKey: - Execute the query.
Note: This works correctly my Parse hosted app. It only becomes an issue when I try to use my parse-server hosted on heroku.
Logs/Trace
[Error]: can only include pointer fields (Code: 102, Version: 1.13.0)
What do you expect to happen? Have the pointers loaded from the array? Or just not having an error?
I expect it to load the pointers from the array. This is how it works on the Parse hosted app and what the documentation says to do.
Alrighty!
I just tried to reproduce the error and I can't reproduce it.
Ok, here's a sample array
[
{
"__type": "Pointer",
"className": "CustomClassName",
"objectId": "yAj8sBKbWn"
},
{
"__type": "Pointer",
"className": "CustomClassName",
"objectId": "VYce892Y3A"
}
]
Where CustomClassName refers to the same class in both instances. Does this look correct?
Can you check the commit that is referenced here and tell me if that embodies your issue?
Any news on that?
It looks like it may fix my issue but I have only been able to successfully set up parse-server using the 2.2.4 release on npm so I haven't been able to test the referenced commit.
Note: I tried setting up my package.json using this but I couldn't get it to work. Node kept reporting that parse-server couldn't be found.
Yeah, you can't set it up like that as the git repository don't hold the lib. If 2.2.4 fixes your issue, that's all good then, I can close the issue. Reopen if you feel there's still a problem
I meant that 2.2.4 is the latest version that I was able to install successfully and it doesn't contain the commit you referenced so I haven't been able to test the fix. The issue still exists in 2.2.4.
Oh right. I'll reopen then and we'll see when 2.2.5 is out
Ok. Thanks @flovilmart, I appreciate your help.
2.2.5 is out! have it a go and let us know!
No luck. I installed 2.2.5 but I'm still getting the same error. I'm trying to think of things that might help with troubleshooting. I'll comment here if I come up with anything.
If you look at the test case here, that seem exactly what you're describing
Yeah, it seems like it should work but I keep getting the error. I decided to run parse-server from master locally using the instructions here and this is the log output when I run the query in question:
verbose: GET /parse/classes/_User { host: 'localhost:1337',
'x-parse-client-version': 'i1.13.0',
accept: '*/*',
'x-parse-session-token': 'sessionToken',
'x-parse-application-id': 'appId',
'x-parse-client-key': 'clientKey',
'x-parse-installation-id': 'installationId',
'x-parse-os-version': '9.3 (15E65)',
'accept-language': 'en-us',
'accept-encoding': 'gzip, deflate',
'content-type': 'application/json; charset=utf-8',
'content-length': '251',
'user-agent': 'MyApp/995 CFNetwork/758.3.15 Darwin/15.4.0',
connection: 'keep-alive',
'x-parse-app-build-version': '995',
'x-parse-app-display-version': '3.0.1' } {
"where": {
"typeOfUser": "aUserType",
"approved": true,
"anArrayOfPointers": {
"$exists": true
},
"location": {
"$exists": true,
"$nearSphere": {
"__type": "GeoPoint",
"longitude": xxx,
"latitude": xxx
}
}
},
"include": "anArrayOfPointers",
"limit": "1000"
}
verbose: error: code=102, message=can only include pointer fields
Check the _SCHEMA class and find the _User row... Is the column you're including definitely an array column?
Just checked and it's definitely an array. This is what it looks like:
{
"_id": "_User",
...
"anArrayOfPointers": "array",
...
}
Can you check where the can only include pointer fields occurs? it's at 2 places in src/RestQuery.js
Looks like the error occurs in the second case:
if (path.length == 0) {
if (object.__type == 'Pointer') {
return [object];
}
throw new Parse.Error(Parse.Error.INVALID_QUERY,
'can only include pointer fields');
}
More specifically, object.__type is undefined so that's why the error is thrown. Not sure why it would be undefined though.