Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tanmays opened this issue Feb 15, 2016 · 4 comments
Closed

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

tanmays opened this issue Feb 15, 2016 · 4 comments
Assignees
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@tanmays
Copy link

tanmays commented Feb 15, 2016

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.

@IliyaGogolev
Copy link

Have similar issue here.

@iatek
Copy link

iatek commented Feb 24, 2016

+1 Same issue here

@flovilmart
Copy link
Contributor

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

@tanmays
Copy link
Author

tanmays commented Mar 3, 2016

@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
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

6 participants