-
Notifications
You must be signed in to change notification settings - Fork 1
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
What's the plan for which filters are supported? #37
Comments
Yes. My plan is to have feature parity across both First, a tad of history/context. Originally, all filter instructions were essentially just dot-separated paths to get to a scalar value followed by a signal that could be passed to that value along with a value attribute. So, for This is less problematic than before (fewer edge case bugs) and also less restrictive (more operations you can use); however, your problem is a central issue with this set up. Another problem is that this still restricts filtering to the So, the plan is to have I'm happy to dig into more detail about any particular aspect of this, so just hit me with whatever follow-up questions. I'm currently working on getting the monorepo version of |
While I'm here, just a note that I pushed out a few point releases today to |
Note: I just published version |
@fractaledmind - Can you tell me what your vision is for the filter API in this gem? At the moment, on
ActiveRecord
sets, all the arel predicates are supported as filters. ForEnumerable
sets, I believe you can use anything as a filter as long as the type you are filtering against supports your filter as a method call.Do you have any particular plan for trying to get
Enumerable
sets to support the arel filters for the sake of ease of use?Here's the situation from which my question arises: I recently had a filter in an application that was using
eq_any
on a "status" field such that the app would support queries where users wanted to return records that matched some number of slected statuses. This "status" field was originally a DB attribute of the model being filtered, but for unrelated reasons, I changed it to be a computed attribute on model instances. That broke my filter, as instead of using arel, suddenly I was calling "string".eq_any(search_criteria) on every instance in my set.After looking into the gem to see what was going on, I quickly realized my error, but it has me wondering if it wouldn't be a good idea to try to standardize the filters here in a way that allows some common core group of filters to be used across both ActiveRecord and Enumerable sets. I think that could be a big win for ease-of-use.
FWIW, I ended up solving my problem by monkeypatching String:
That's obviously a hack that is very specific to the particular filter and datatype that I happened to be working with.
One thought I had was that we may be able to use
method_missing
here to define some of the arel filters on native datatypes such that they will work when passed as filters on enumerabe sets. But, before I did anything like that I thought I'd get your thoughts on what sorts of filters should be supported Enumerable sets or if this gem should do anything to try to have a standard set of filtering signals that work regardless of the set type.The text was updated successfully, but these errors were encountered: