Bug 14816

Summary: Item search returns no results with multiple values selected for one field
Product: Koha Reporter: Kyle M Hall <kyle.m.hall>
Component: SearchingAssignee: Julian Maurice <julian.maurice>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: brendan, f.demians, jonathan.druart
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 14816: Fix multiple selection in item search
Bug 14816: Fix multiple selection in item search
Bug 14816: Fix multiple selection in item search
Bug 14816: Fix multiple selection in item search
[SIGNED-OFF] Bug 14816: Fix multiple selection in item search
Bug 14816: Fix multiple selection in item search

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.