Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

equalTo filters for join tables with pointers, on an observed query, return no results #21

Open
jsierles opened this issue Apr 20, 2015 · 13 comments

Comments

@jsierles
Copy link

equalTo works as expected when testing outside of React Native in a nodejs script.

However, when observing the same query in RN, no results are returned.

  observe(props, state) {
    query = new Parse.Query('PracticeSessionResource');
    query.equalTo("practice_session", props.practice_session);
    query.include("practice_resource");
    query.include("practice_session");

    return ({
      session_resources: query
    });
  },
@jsierles
Copy link
Author

The error provided by Parse is: "pointer field practice_session needs a pointer value"

Despite the fact that I'm passing in an object supplied from the include filter on a previous query.

@agnosticdev
Copy link

Do you need to do a find(); on the query?

  return ({
      session_resources: (query.find())
   });

@jsierles
Copy link
Author

According to the docs, the observed queries should not be fetched prematurely.

@jsierles
Copy link
Author

The issue also happens if I test with find() separately, though. The problem seems to be related to the object passed in to equalTo. This doesn't work either, though:

query.equalTo("practice_session", {
      __type: "Pointer",
      className: "_PracticeSession",
      objectId: this.props.practice_session.objectId
    });

@jsierles
Copy link
Author

Sorry - the above code in fact does work, I mistyped the className. So this is a workaround, but it would be nice to be able to use the cloned objects returned by the observer to query a pointer field.

@andrewimm
Copy link
Contributor

I'll think of the best way to handle this without patching too much of Parse.Query under the hood.
In the meantime, you can actually achieve the same behavior above with minimal boilerplate:

q.equalTo('practice_session', Parse.Object('_PracticeSession',
  { id: this.props.practice_session.objectId }));

@jsierles
Copy link
Author

That works for now - thanks!

@agnosticdev
Copy link

@andrewimm - thank you! Your snippet above works great.

@ghost
Copy link

ghost commented Aug 4, 2015

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

@WilfredGreyling
Copy link

Thank the stars for your solution! I was losing my mind.

@albertolive
Copy link

It worked for me doing it like this (Parse.Object.extend):

var query = new Parse.Query('Inscription');
query.equalTo('jobOffer', Parse.Object.extend('Offer', { id: this.props.params.offerId}));
query.equalTo('user', Parse.Object.extend('User', { id: this.props.params.userId}));

@WilfredGreyling
Copy link

They have fixed this issue.
You can now supply the object directly:
newQuery: (new Parse.Query('parseClassName'))
.equalTo('myPointerField', myParseObject )

@albertolive
Copy link

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants