Bug 14816 - Item search returns no results with multiple values selected for one field
Summary: Item search returns no results with multiple values selected for one field
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Julian Maurice
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-14 13:09 UTC by Kyle M Hall
Modified: 2016-12-05 21:25 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 14816: Fix multiple selection in item search (1.61 KB, patch)
2016-01-07 14:43 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 14816: Fix multiple selection in item search (1.93 KB, patch)
2016-01-08 14:39 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 14816: Fix multiple selection in item search (1.98 KB, patch)
2016-01-11 23:01 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 14816: Fix multiple selection in item search (1.48 KB, patch)
2016-04-06 11:50 UTC, Julian Maurice
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 14816: Fix multiple selection in item search (1.78 KB, patch)
2016-04-06 13:02 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 14816: Fix multiple selection in item search (1.79 KB, patch)
2016-04-06 14:41 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2015-09-14 13:09:49 UTC
If you select multiple values from the pulldown for a give field ( e.g. home library ), the search will never return results. I believe this issue is due to the fact that the query is using IN but is treating the entire list of values for the IN as a single string to be quoted, instead of a list of comma separated string to be quoted individually.

'str' => '(homebranch IN (?))'
'args' => 'CPL,FFL,FPL,FRL,IPT,LPL,MPL,MY,PVL,RPL,SPL,TPL,UPL'
Comment 1 Julian Maurice 2016-01-07 14:43:39 UTC Comment hidden (obsolete)
Comment 2 Marc Véron 2016-01-08 14:39:09 UTC Comment hidden (obsolete)
Comment 3 Aleisha Amohia 2016-01-11 23:01:31 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2016-01-13 11:19:34 UTC
Julian,
I'd suggest to simplify with something like:
  $form.find('select').not('[disabled]').find('option:selected').each(function () {

I have tried and it seems to work, please confirm.
Comment 5 Julian Maurice 2016-04-06 11:50:34 UTC Comment hidden (obsolete)
Comment 6 Julian Maurice 2016-04-06 12:00:18 UTC
(In reply to Jonathan Druart from comment #4)
> Julian,
> I'd suggest to simplify with something like:
>  
> $form.find('select').not('[disabled]').find('option:selected').each(function
> () {
> 
> I have tried and it seems to work, please confirm.

Yep, much better, thanks.

I removed the signoffs (sorry Marc and Aleisha), so I reset status to Needs signoff
Comment 7 Owen Leonard 2016-04-06 13:02:13 UTC Comment hidden (obsolete)
Comment 8 Jonathan Druart 2016-04-06 14:41:56 UTC
Created attachment 49977 [details] [review]
Bug 14816: Fix multiple selection in item search

Send each selected value as a separate parameter. Otherwise DataTables
(or jQuery ?) joins all values with a comma

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

I could not reproduce the bug when selecting multiple home libraries,
but I could by selecting multiple item types or collection codes. The
patch allowed those queries to complete correctly.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Brendan Gallagher 2016-04-20 21:01:42 UTC
Pushed to Master - Should be in the May 2016 Release.  Thanks!
Comment 10 Julian Maurice 2016-04-21 07:42:44 UTC
Patch pushed to 3.22.x, will be in 3.22.6
Comment 11 Frédéric Demians 2016-04-27 15:33:04 UTC
Pushed to 3.22.x, will be in 3.20.11.