All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

IS_EMPTY not handled by Low Search for "select" fields.

Chris 15 Apr 2015 15:33 problem, complete

Currently Grid search doesn't handle "IS_EMPTY" correctly for certain field types. A multi-select for example stores an empty value as NULL.

I've updated the code (which I hate doing)

file "filter.low_search.php"
method "_get_where_search"
line 228

instead of:
$sql[] = sprintf("(%s %s %s)", $field, $operand, $item);

I've added a bit of a plaster:
$temp_sql = sprintf("(%s %s %s)", $field, $operand, $item);
if($empty){
$temp_sql = sprintf(
"(%s OR (%s %s %s))",
$temp_sql,
$field,
(($exclude) ? 'IS NOT' : 'IS'),
"NULL"
);
}

$sql[] = $temp_sql;

Replies

  1. Low 15 Apr 2015 15:48

    Thanks for reporting. I'll look into it.

    For now, if you want to remove the hack, you can also disallow NULL on a DB level for that Grid column. That should force EE to use an empty string instead of a NULL value.

    Low 15 Apr 2015 15:52

    Note to self: EE doesn't support NULL values natively with their search:field_name params, as per EE2.9.3, channel_model::_field_search() (line #597).

    Low 15 Apr 2015 15:58

    Can confirm this behaviour is equal to native EE behaviour, eg:

    {grid_field search:column="IS_EMPTY"}


    ...will not return rows with NULL values.

  2. Low 17 Apr 2015 12:31

    FYI: as this behaves the same as native EE stuff, it was marked as a bug there: https://support.ellislab.com/bugs/det...

  3. Low 23 Apr 2015 09:18

    Should be fixed in LS 4.2.0.