ParseReact
ParseReact copied to clipboard
equalTo filters for join tables with pointers, on an observed query, return no results
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
});
},
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.
Do you need to do a find(); on the query?
return ({
session_resources: (query.find())
});
According to the docs, the observed queries should not be fetched prematurely.
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
});
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.
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 }));
That works for now - thanks!
@andrewimm - thank you! Your snippet above works great.
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.
Thank the stars for your solution! I was losing my mind.
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}));
They have fixed this issue. You can now supply the object directly: newQuery: (new Parse.Query('parseClassName')) .equalTo('myPointerField', myParseObject )
Thank you!