Skip to content

Parse.Query.or ignores query on relation field #432

Closed
@tanmays

Description

@tanmays

Hello,

I'm trying to run a compound query where in I want to match a pointer to a field which is of type relation. Here's my request:

GET /parse/classes/Activity { 'user-agent': 'node-XMLHttpRequest, Parse/js1.7.0 (NodeJS 4.2.6)',
  accept: '*/*',
  'content-type': 'text/plain',
  host: 'localhost:1337',
  'content-length': '422',
  connection: 'close' } {
  "where": {
    "$or": [
      {
        "toUsers": {
          "__type": "Pointer",
          "className": "_User",
          "objectId": "NSME8tT0tf"
        }
      },
      {
        "toUser": {
          "__type": "Pointer",
          "className": "_User",
          "objectId": "NSME8tT0tf"
        }
      }
    ]
  },
  "limit": 100,
  "order": "-updatedAt"
}

In the above request toUsers is a column of type relation while toUser is of type pointer. The results simply ignore the 'toUsers' query and returns results matching pointer column. Running these two queries separately works.

Here's the cloud code of the above request:

Parse.Cloud.define("GetActivity", function(request, response) {

  var Activity = Parse.Object.extend("Activity");
  var User = Parse.Object.extend("User");

  var user = request.user;

  var queryPings = new Parse.Query(Activity);
  queryPings.equalTo("toUsers", user);

  var queryFollows = new Parse.Query(Activity);
  queryFollows.equalTo("toUser", user);

  var query = Parse.Query.or(queryPings, queryFollows);
  query.descending("updatedAt");
  query.limit(100);

  query.find().then(function(activities) {
    response.success(activities);
    }, function(error) {
      response.error(error);
  });

}); 

Just to try out whether compound queries were working or not, I tested it with values on normal string based columns and that worked fine. It seems the problem only occurs on compound queries involving relation type column. I'd also like to add that this code works well with the parse hosted server.

Metadata

Metadata

Assignees

Labels

type:bugImpaired feature or lacking behavior that is likely assumed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions