Skip to content

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

Closed

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.

Activity

  1. IliyaGogolev commented on Feb 23, 2016

    @IliyaGogolev

    Have similar issue here.

  2. iatek commented on Feb 24, 2016

    @iatek

    +1 Same issue here

  3. added
    type:bugImpaired feature or lacking behavior that is likely assumed
    on Feb 26, 2016
  4. flovilmart commented on Mar 2, 2016

    @flovilmart
    Contributor

    This should be fixed with #769, please test against that version and let me know if that's still occuring

  5. tanmays commented on Mar 3, 2016

    @tanmays
    Author

    @flovilmart just tried and at least in this particular case it seems to be working well! Will test more in depth later and re-open if I find an issue. Thanks man and as always great job 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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