scoped_search
scoped_search copied to clipboard
Add enhanced filter to autocomplete
This PR adds a new field, enhanced_filter
to AutoCompleteBuilder
.
enhanced_filter
takes the following arguments:
-
has_column
- Name of the required column -
filter
- Predicate used for filtering
Iff in the table to be filtered, there exists a column <has_column>
, the filter will be executed.
Consider the following example:
Let's say the table Food is populated with a green apple and a red pepper.
If I want to filter for green food, I would do value_filter: {color_id: <green_id>}
.
This works as long as a user doesn't try to filter this by type =
. In that case, value_filter
will be applied to the table Type, which doesn't have a color_id
column, causing an exception.
enhanced_filter
prevents this by first checking for the existence of the required column before filtering.