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
Queries with the form: 'value != prop' return entries where 'prop == None' #1133
Comments
Hmm, I remember adding this as an explicit edge case with MongoDB here: optimade-python-tools/optimade/filtertransformers/mongo.py Lines 106 to 109 in 0fb4423
I guess it just needs to be percolated down to the "constant first" expression style. Perhaps you could add some tests outside of the trajectories PR that tests some reversed queries like this? I think we have a few already but maybe != isn't tested atm. |
There is an automatically generated test in _construct_single_property_filters in validator.py. The property first query indeed passes the line of code you mentioned. I did notice that the lark parser seems to interpret each of these cases differently, although I am not sure whether this is the cause of the problem. (I left the part of the tree, that is the same for both, out) Incase of '"10.1145/362929.362947" != doi' the lark parser interprets it as : constant_first_comparison(constant(string("10.1145/362929.362947")), token(!=), non_string_value('property'(doi)) Incase of 'doi != "10.1038/335201a0"' the lark parser interprets it as : 'property_first_comparison'('property'(doi),'value_op_rhs'(!=,'value'('string'("10.1038/335201a0")))) |
Yeah, ideally we should be able to call |
I think I have an idea of how to solve it. |
I noticed that handling the $ne and the $size operator in I also seem to be able to call |
This is a MongoDB limitation, you can't do We could implement |
I have put it on my private low priority to-do list. Probably most of the things on that list will however never get done. |
For the trajectory endpoint, I added a few references without DOI values.
A query like https://optimade-trajectories.herokuapp.com/v1/references?filter=%2210.1038/00000%22!=doi returned 4 entries, while the query
https://optimade-trajectories.herokuapp.com/v1/references?filter=doi!=%2210.1038/00000%22 returns 2 entries
This also applies to other reference properties like journal and year.
The text was updated successfully, but these errors were encountered: