0
votes

I have ParseObject subclass called Note and it has column owner which is a pointer to the User class (ParseUser). I also have a ownerSignedOut column on my object class and when only using that as "rule" it works fine.

Adding the owner "rule" gives me no results.


Note has these columns:

  • objectId (String)
  • owner (Pointer <_User>)
  • ownerSignedOut (Pointer <_Installation>)
  • title (String)
  • createdAt (Date)
  • updatedAt (Date)
  • ACL (ACL)

Trying to only get objects that belong to a specific owner or ownerSignedOut

List<ParseQuery<Note>> queries = new ArrayList<ParseQuery<Note>>();

ParseQuery<Note> query1 = ParseQuery.getQuery( Note.class );
query1.whereEqualTo( "owner", ParseUser.getCurrentUser() );
queries.add( query1 );

ParseQuery<Note> query2 = ParseQuery.getQuery( Note.class );
query2.whereEqualTo( "ownerSignedOut", ParseInstallation.getCurrentInstallation() );
queries.add( query2 );

ParseQuery<Note> query = ParseQuery.or( queries );
query.addDescendingOrder( "updatedAt" );
query.findInBackground( new FindCallback<Note>() {
    // other code

  • Using only query1 gives me no results
  • Using only query2 gives me the correct results
  • Using query1 & query2 gives me no results

Edit: Here you can see the pointers working fine A picture showing the objects and their pointers


Edit 2: This is how I create the objects:

if ( ParseUser.getCurrentUser() != null && ParseUser.getCurrentUser().getUsername() != null ) {
    noteItem.put( "owner", ParseUser.getCurrentUser() );
}

noteItem.put( "title", title );
noteItem.put( "ownerSignedOut", ParseInstallation.getCurrentInstallation() );
noteItem.saveInBackground( new SaveCallback() {
    @Override
    public void done( ParseException e ) {
        setResult( 1 );
        finish();
    }
} );

Edit: My Installation class has user column that is a pointer to User class. Can it be a conflict there?

1
The fact that query1 doesn't work makes me think that the current user isn't the same user that is saved in the Note class. Can you verify that they are the same?Kirk
Yes they are the same, and if I press the "Epx7PVcmrx" in the owner column i get to the right user in the User class.Jonas Borggren
And the result of ParseUser.getCurrentUser().getObjectId(); matches that as well?Kirk
Exactly. It seems to work fine it's just the query that is wrong.Jonas Borggren

1 Answers

0
votes

Shot in the dark here, but have you tried just adding to one query vs. multiple?

ParseQuery<Note> query1 = ParseQuery.getQuery( Note.class );
query1.whereEqualTo( "owner", ParseUser.getCurrentUser() );
query1.whereEqualTo( "ownerSignedOut", ParseInstallation.getCurrentInstallation() );
queries.add(query1);