Generate a condition when value is false for boolean predicates#335
Conversation
lib/ransack/constants.rb
Outdated
There was a problem hiding this comment.
I don't understand why we need inverse_of_true and not_true and false. These seem like really confusing predicate names. Especially when you get to inverse_of_not_true. So... not true would be false, but the inverse of that would mean true? If so, then why not use the true predicate?
There was a problem hiding this comment.
I agree that the implementation is confusing. The inverse_of_... predicates are simply a way to accept false values. I can try to implemented it in another way, removing the need for these strange predicates. I also accept suggestions. :)
However, the not_true and false predicates are not equivalent if you consider NULL values. For example, the true predicate will only match true values, the false predicate will only match false values, but the not_true predicate will match false and NULL values, which is the real inverse of the true predicate. But this can be an issue/request on its own.
|
Thanks, @PChambino. I believe this issue has just been fixed yesterday, but your solution is interesting and different from the one merged in; I'll have a look at it and at your tests and see what could be merged in. |
|
Yes, #370 already fixes this issue. I still think there are some missing aspects that should be considered.
What do you think of this two points? |
|
I patched around this in our codebase by redefining Related: #123 |
5aa3815 to
752dc78
Compare
|
Updated to include |
Add `not_true` and `not_false` predicates
|
Thanks Pedro! Could you add these predicates to the |
|
Sure! I took a shoot at it already. Added the |
|
Thanks! Seems good. I added a second sentence: Hope that is correct. |
|
In the second sentence I was actually expecting to read:
But I guess it depends on what you think "Otherwise" is referring to. What do you think about rewriting it to something like:
|
|
I see. Maybe the explanation should be more explicit? |
I noticed that for boolean predicates the value
falseis being ignored. This can be counterintuitive as I would expect thatname_present = falsewould give me all records wherenameequalsNULLor is empty.I found this issue #9 and implemented something starting from @cawel spec.
I am not sure if it is the best approach, but let me know what you think.