Combination of notEqualTo is not working
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!
- [x] You've met the prerequisites.
- [x] You're running the latest version of Parse Server.
- [x] You've searched through existing issues. Chances are that your issue has been reported or resolved before.
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 😬 😉 🎉
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:
- Fork/clone the repo and
cdto it npm installnpm test
If you have issues somewhere in there, let us know.
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?
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! 🎉 😢
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.
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 ? 😬
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.
YES! I added jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000 and it does the trick
I'm writing the test case then, thanks
@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 🙏
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...
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.
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.
@Michael-Kr What version of parse-server are you running?
"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.
@Michael-Kr If your equalTo is on objectId, then #2472 will fix this.
@Michael-Kr can you provide come code, examples so we can investigate your issue further?