Skip to content

Using includeKey: on array of pointers results in error #1293

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

Closed
3 tasks done
N4tr0n opened this issue Mar 31, 2016 · 29 comments
Closed
3 tasks done

Using includeKey: on array of pointers results in error #1293

N4tr0n opened this issue Mar 31, 2016 · 29 comments
Assignees
Labels
type:question Support or code-level question

Comments

@N4tr0n
Copy link

N4tr0n commented Mar 31, 2016

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!

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.

  1. Create a PFQuery on the object's type.
  2. Try to include the array of pointers field using includeKey:
  3. 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)

@flovilmart
Copy link
Contributor

What do you expect to happen? Have the pointers loaded from the array? Or just not having an error?

@N4tr0n
Copy link
Author

N4tr0n commented Mar 31, 2016

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.

@flovilmart
Copy link
Contributor

Alrighty!

@flovilmart
Copy link
Contributor

I just tried to reproduce the error and I can't reproduce it.

@N4tr0n
Copy link
Author

N4tr0n commented Mar 31, 2016

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?

@flovilmart
Copy link
Contributor

Can you check the commit that is referenced here and tell me if that embodies your issue?

@flovilmart
Copy link
Contributor

Any news on that?

@N4tr0n
Copy link
Author

N4tr0n commented Apr 4, 2016

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.

@flovilmart
Copy link
Contributor

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

@N4tr0n
Copy link
Author

N4tr0n commented Apr 4, 2016

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.

@flovilmart
Copy link
Contributor

Oh right. I'll reopen then and we'll see when 2.2.5 is out

@flovilmart flovilmart reopened this Apr 4, 2016
@N4tr0n
Copy link
Author

N4tr0n commented Apr 4, 2016

Ok. Thanks @flovilmart, I appreciate your help.

@flovilmart
Copy link
Contributor

2.2.5 is out! have it a go and let us know!

@N4tr0n
Copy link
Author

N4tr0n commented Apr 5, 2016

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.

@flovilmart
Copy link
Contributor

If you look at the test case here, that seem exactly what you're describing

@N4tr0n
Copy link
Author

N4tr0n commented Apr 5, 2016

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

@gfosco
Copy link
Contributor

gfosco commented Apr 5, 2016

Check the _SCHEMA class and find the _User row... Is the column you're including definitely an array column?

@N4tr0n
Copy link
Author

N4tr0n commented Apr 5, 2016

Just checked and it's definitely an array. This is what it looks like:

{
    "_id": "_User",
    ...
    "anArrayOfPointers": "array",
    ...
}

@flovilmart
Copy link
Contributor

Can you check where the can only include pointer fields occurs? it's at 2 places in src/RestQuery.js

@N4tr0n
Copy link
Author

N4tr0n commented Apr 5, 2016

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.

@flovilmart
Copy link
Contributor

try console.log the object?

@N4tr0n
Copy link
Author

N4tr0n commented Apr 5, 2016

Here's the log of the object: { objectId: 'mpImkB2Zyw' } Don't know why the __type and className fields aren't there.

@flovilmart
Copy link
Contributor

Maybe because they have been improperly stored... Are all your objects like that? What's your client code that creates those objects? try removing the throwing, and ignore the unproperly configured objects by returning an empty array, see if many/most of those are improperly stored.

@N4tr0n
Copy link
Author

N4tr0n commented Apr 6, 2016

Yeah, that was the problem. I remember we had some issues with this array when adding a web client. Anyway, I found two users that had bad arrays. After I removed the bad arrays the query worked perfectly. I guess on the Parse hosted apps the bad arrays are ignored.

Thanks again for all your help, it is truly appreciated.

@flovilmart
Copy link
Contributor

May be, let's close that for now.

@lguerra10
Copy link

I have the same problem with arrays of PFUsers and PFFIles.
What should I do, rewrite the code so as to avoid this type of arrays or wait for this problem to solved?
Is the problem being addressed so that we can expect it to be solved?

@xissburg
Copy link

xissburg commented Jun 3, 2016

I am also getting arrays of pointers like this in my database sometimes:
[{"objectId":"9m2llSTANa"},{"objectId":"Rtu7IEU9cT"}]

Instead of
[{"__type":"Pointer","className":"_User","objectId":"1Nii4IsZc1"},{"__type":"Pointer","className":"_User","objectId":"Glivar389e"}]

@xissburg
Copy link

xissburg commented Jun 3, 2016

In a query when I do this query.includeKey("users") I get no results. When I remove this includeKey I get results but without the users objects of course (I mean, no data available). This is my full query:

let query = Chat.query()!
query.whereKey("users", equalTo: user)
query.includeKey("users")

Funny how if I remove that whereKey I get error can only include pointer fields.

@rickyjwhong
Copy link

rickyjwhong commented Jul 27, 2016

Hello, same error we see here. An array of PFObjects are only returning partial data instead of full, even with includeKey. It works fine with just a single pointer however.

@mtrezza mtrezza added type:question Support or code-level question and removed 🔧 troubleshooting labels Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

7 participants