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

equalTo and notEqualTo don't work on relations #1349

Closed
3 tasks done
lolobosse opened this issue Apr 3, 2016 · 8 comments
Closed
3 tasks done

equalTo and notEqualTo don't work on relations #1349

lolobosse opened this issue Apr 3, 2016 · 8 comments

Comments

@lolobosse
Copy link

Good afternoon,

I tried to use the code I wrote for Parse.com (some CloudCode stuff) on parse-server and it seems that there is a bug with the equalTo and notEqualTo methods.

Some issues have been fixed like #801 but it seems that the bug still exists.

I wrote a test case to illustrate the bug (got a lot of trouble doing it and I could have written it in a much better way but it shows the bug! 😄 💪 )

Basically the use case is the following: you have two lists -> on one side you have the guys who love a cake ( 🍰 😋 !) and on the other hand, you have the guy who hate this very same cake (😠). In particular in my test case, the user2 likes no cake and is a hater of possible cakes.

So if I ask for: Give me all the cakes where the user2 is NOT a hater it should return null. It actually returns 3...

Translated into code:

var query = new Parse.Query(Cake);
query.notEqualTo("hater", user2);

returns 3 instead of 0.

Did I miss something?

Environment Setup

VERBOSE=1
Parse-Server 2.2.4

@flovilmart
Copy link
Contributor

@lolobosse that test case is awesome! I guess that makes you understand how complex it is for us to reproduce bugs and make sure we don't hit regression! :)

In any case we'll look at it shortly!

just a quick question, does the equalTo works?

@lolobosse
Copy link
Author

@flovilmart yes, I can remember that it worked but this is a good idea, I'll update my test case

@flovilmart
Copy link
Contributor

ok thanks!

@lolobosse
Copy link
Author

Soooo, I made a much deeper test and tested, I hope almost every possibility except combinations (combinations should work but I didn't test that): here

For the lazy ones, here is the interesting part 😄 :

then(function(){
  var query = new Parse.Query(Cake);
  // User2 likes nothing so we should receive 0
  query.equalTo("liker", user2);
  return query.find().then(function(results){
    equal(results.length, 0);
  });
}).then(function(){
  var query = new Parse.Query(Cake);
  // User1 likes two of three cakes
  query.equalTo("liker", user1);
  return query.find().then(function(results){
    // This test fails on 2.2.4
    // It should return 2 -> cake 1 and cake 2
    equal(results.length, 2);
  });
}).then(function(){
  var query = new Parse.Query(Cake);
  // We want to know which cake the user1 is not appreciating -> cake3
  query.notEqualTo("liker", user1);
  return query.find().then(function(results){
    // This test fails on 2.2.4
    // Should return 1 -> the cake 3
    equal(results.length, 1);
  });
}).then(function(){
  var query = new Parse.Query(Cake);
  // User2 is a hater of everything so we should receive 0
  query.notEqualTo("hater", user2);
  return query.find().then(function(results){
    // This test fails on 2.2.4
    equal(results.length, 0);
});

@flovilmart
Copy link
Contributor

I skimmed through the code and it looks like we don't support it as it is.
I believe that was working on parse.com so I'll do my best to implement it.

@lolobosse
Copy link
Author

Cool! Yes, it was working on Parse.com; I know that I'm playing with the limits of the system and if you decide not to implement it, I have the possibility to do something else BUT I think it is a good target to have the exact same characteristics as Parse.com!

And if you do not do it, please document it properly so that it is clear from the beginning that this system is a bit more limited than Parse.com

@flovilmart flovilmart changed the title notEqualTo doesn't seem to work notEqualTo doesn't seem to work on relations Apr 3, 2016
@flovilmart flovilmart changed the title notEqualTo doesn't seem to work on relations equalTo and notEqualTo don't work on relations Apr 3, 2016
@flovilmart
Copy link
Contributor

We aim to feature parity, and you have written the test case, 90% of the work is done :)

flovilmart pushed a commit that referenced this issue Apr 3, 2016
flovilmart pushed a commit that referenced this issue Apr 4, 2016
flovilmart added a commit that referenced this issue Apr 4, 2016
@flovilmart
Copy link
Contributor

So I checked, equalTo was actually working, some of your tests had some faulty design.

Just opened the PR, waiting for the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants