-
Notifications
You must be signed in to change notification settings - Fork 37
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
Boolean value representation in queries #345
Comments
Thank you for your interest and the issue! The issue of boolean type usage in the filter language indeed never came up (as far as I remember), as you rightly suggest, due to a lack of filter fields needing boolean values. Personally, I would follow your suggestion here and use the JSON style boolean values |
Thanks for the prompt reply! Regarding the use of |
Since Concerning the issue of naming a field's value (e.g., For the single-entry endpoint (´/structures/true`) it shouldn't be an issue either, since the filter parser never touches this part of the URL. Whether a field's name could be |
Issue well spotted! I think all-caps
By the way, endpoint names may appear in filters as explained in "Filtering on relationships".
Moreover, I would go for using |
This is definitely an oversight and should be fixed for v1.0.1, thanks @lauri-codes (also hello, hope you're good!)
I like this suggestion, we need to make it clear that |
Hi @ml-evs, long time no see :) If boolean values are always assumed to be scalar-like, then What about queries that would target lists containing booleans? Would they be supported? E.g.
If boolean values can be used together with other operators besides equality/unequality, then I would prefer keeping the operators as they are ( |
I am surprised we've missed this so far, thanks for pointing it out. The reason is of course that we so far did not yet need to standardize a boolean field. Formally the filter language supports comparison of boolean fields, but there is just no way to express a boolean constant, nor an operator to test for "truthiness" in a filter. Since this is likely to require a grammar extension (though, depending on where we land, maybe not) and this will take some time to make it into the standard, I would suggest that @lauri-codes may try to find some form of workaround solution for now. If you have several "flags" you want to represent and query against, consider representing them as strings in a list like the standardized We definitely should be careful with introducing lowercase keywords, e.g. My first thought was also towards 'IS TRUE', which then isn't a boolean constant token, but an operator to test for truthiness. However, I think it would be more consistent with the present language design to find another word than "IS" for truthiness operators. Not sure what it would be though. (Also - I see that @lauri-codes just posted the objection that it is not clear how this generalizes to testing boolean values in lists.) However, it would actually be consistent with how we handled timestamps to simply say that the OPTIMADE representation of booleans in the filter language is via the strings |
I think Whether |
I support |
The more I think, the more I like the idea of |
Surely we can say that the only valid comparison operator for booleans is equality? Note: |
Either that, or specify that when compared,
Yes, I think that doing so would require many additional grammar rules. |
Hi!
First of all thanks for all your hard work on this great project!
I'm just getting to know the different standards that Optimade provides, and I bumped into a problem with boolean values. The documentation (optimade.rst) at 2.1 says that there are the following basic types: string, integer, float, boolean, timestamp. In section 4.2. it is mentioned that booleans in responses should use the JSON standard. However, the standard is unclear on how boolean values should be represented in the queries. Section 6.1 discusses the different tokens, but also there is no mention of how boolean values should be presented. The grammar itself also does not seem to define a token for booleans.
So the question is whether I just somehow missed how booleans are to be defined, or if the official standard is missing? I guess none of the current entries are of boolean type, so this was never discussed. I would, however, like to apply the Optimade query language to a domain which also contains boolean values. My naive suggestion would be to go with the JSON style lowercase
true
/false
values.Thanks fo your time!
The text was updated successfully, but these errors were encountered: