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

Combination of notEqualTo is not working #1596

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

Combination of notEqualTo is not working #1596

lolobosse opened this issue Apr 22, 2016 · 15 comments
Labels
type:question Support or code-level question

Comments

@lolobosse
Copy link

Check out this issue for an ideal bug report. The closer your issue report is to that one, the more likely we are to be able to help, and the more likely we will be to fix the issue quickly!

For implementation related questions or technical support, please refer to the Stack Overflow and Server Fault communities.

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Hi there,

I think we're not totally done with the issue #1349 and the PR #1350 just solved it partially...

@drew-gross thought that we will be running into trouble for combination and he was... right 😢

I tried to extend the test cases but there is no guide of how to run the server properly and I got some weird errors everytime (btw is there a runnable docker with proper instruction that can be run on a shitty machine just to do the tests?)

So I'll try to explain the problem as precisely as possible: "You have a cake and this cake has fan and haters".

If you want to see the cakes that Mister X didn't rated yet, you will (on Parse.com) have something like this:

var queryCake = new Parse.Query(Cake);
queryCake.notEqualTo("likes", MisterX);
queryCake.notEqualTo("dislikes", MisterX);

And, logically it returns you: all the cakes - the cakes he likes - the cakes he dislikes = all the cakes he doesn't have a opinion on or the cakes he doesn't know about.

The current status:
At the moment, it works really well with one condition but the intersection is not working, I guess: I can have all the cakes he doesn't know about or he hates (noIdea || dislike) or all the cakes he doesn't know about or he likes (noIdea || like).

My knowledge about mongo are pretty limited but is this possible that the two conditions are joined with a or and not with an and (as it logically should)?

Nevertheless, I can make two queries and the intersection myself but that's really bad design to me...

If someone gives me access to a working test machine or provide me a decent tutorial which works on a shitty linux, I promise to write the test case myself 😬 😉 🎉

@drew-gross
Copy link
Contributor

Thanks for the bug report, we will look into this. In the meantime, if you want to build and run from source, it should just be 3 steps, assuming you already have git and node installed:

  1. Fork/clone the repo and cd to it
  2. npm install
  3. npm test

If you have issues somewhere in there, let us know.

@lolobosse
Copy link
Author

So, for instance, if the test fail here because Cannot read property id of undefined, it is because of a bad configuration or it is there a regression bug?

@lolobosse
Copy link
Author

I thought every test was working that's why I was asking for a proper tutorial but if they're failing also on your machine, then that's...fine! 🎉 😢

@drew-gross
Copy link
Contributor

That test works on both my machine and Travis. To debug, change the it to fit to run only that test, then run VERBOSE=1 npm test to see the server logs as you run the tests. That may help you debug.

@lolobosse
Copy link
Author

Ok, got Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL so can it be that my machine is a bit too slow ? 😬

@drew-gross
Copy link
Contributor

That could be it. You can increase the timeout for that one test by passing a 3rd parameter to it, like

it('test name', done => {
  //test stuff
  done();
}, 60000)

Or change the default when testing on your machine.

That test also doesn't have a catch block, so adding on a catch at the end may expose the true error.

@lolobosse
Copy link
Author

YES! I added jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000 and it does the trick

I'm writing the test case then, thanks

lolobosse pushed a commit to lolobosse/parse-server that referenced this issue Apr 22, 2016
@lolobosse
Copy link
Author

lolobosse commented Apr 22, 2016

@drew-gross It should do the trick: the test is failing -> every cake is returned but only cake3 should be present.

The comment on the test is really shit (I think I mixed two sentences in my head 😬 ). What I meant is that the cake3 doesn't have any relation with the user1 whereas the others do.
The notEqualTo should remove the cake1 and cake2 from the list but they, obviously, don't.

Hope it is clearer yet and hope you can fix it for our release on Monday 🙏

@Michael-Kr
Copy link

Hi, is there any news about this issue?
Maybe some ways to fix it without waiting for issue fixing?
It is very important for me, the application, which i am trying to migrate right now, is totally build on relations and queries with combinations of equalTo/notEqualTo...

@gulo-gulo
Copy link

how about giving this a shot? I'm not sure if the behavior is exactly what you are looking for

var queryCakeLikes = new Parse.Query(Cake);
queryCakeLikes.notEqualTo("likes", MisterX);

var queryCakeDislikes = new Parse.Query(Cake);
queryCakeDislikes.notEqualTo("dislikes", MisterX);

var queryCakes = Parse.Query.or(queryCakeLikes, queryCakeDislikes);
queryCakes.find() //etc.

@Michael-Kr
Copy link

Unfortunately it will only work if i need OR, but most of all i need AND.
Anyway it is a real problem, because i need to rewrite code which works with old parse perfectly.

@flovilmart
Copy link
Contributor

@Michael-Kr What version of parse-server are you running?

@Michael-Kr
Copy link

"parse": "~1.9.0",
"parse-server": "~2.2.16",
Query construction:
query.equalTo("StringProperty", StringValue);
query.notEqualTo("RelationProperty", objectId of some Object);
query.limit(1);

The result of this query is pretty weird, the finded object does not complies to the 'query.equalTo("StringProperty", StringValue);' constraint.
At parse servers everything works correctly.

@JeremyPlease
Copy link
Contributor

@Michael-Kr If your equalTo is on objectId, then #2472 will fix this.

@flovilmart
Copy link
Contributor

@Michael-Kr can you provide come code, examples so we can investigate your issue further?

JeremyPlease added a commit to JeremyPlease/parse-server that referenced this issue Oct 18, 2016
Multiple  should use the union of all objectIds not the intersect
Fixes parse-community#1596
flovilmart pushed a commit that referenced this issue Oct 18, 2016
* Add failing test for multiple .notEqualTo on relation with same class

* Fix multiple .notEqualTo on relations with the same class

Multiple  should use the union of all objectIds not the intersect
Fixes #1596
@mtrezza mtrezza added type:question Support or code-level question and removed 🔧 troubleshooting labels Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

7 participants