Bug 18961: Use exact match for select filters on item search

The SQL operator LIKE is always used for filters when searching for
items.

If the filter is a select, we should search for an exact match.
That way we avoid problematic search like "%NFIC%" and "%FIC%" (one
includes the other one).

Test plan:
- Make sure you have collection codes 'Fiction' and 'Non-fiction'
- Do an item search
- Filter column 'Collection', select 'Fiction'
- Result: Column contains items from Fiction only

Followed test plan, works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2017-10-10 12:18:10 -03:00
parent 7ed705ea45
commit f0f3cb3288
1 changed files with 8 additions and 2 deletions

View File

@ -61,9 +61,15 @@ if (defined $format and $format eq 'json') {
my @words = split /\s+/, $sSearch;
foreach my $word (@words) {
push @f, $columns[$i];
push @q, "%$word%";
push @op, 'like';
push @c, 'and';
if ( grep /^$columns[$i]$/, qw( ccode homebranch holdingbranch location notforloan ) ) {
push @q, "$word";
push @op, '=';
} else {
push @q, "%$word%";
push @op, 'like';
}
}
}
}