Datatable column filters of type select do not do an exact match. E.g. for a select with values 'Fiction' and 'Non-fiction', filtering after 'Fiction' will match both. To reproduce: - Apply patch of Bug 16485 - Collection column in Item search is always empty - Make sure you have collection codes 'Fiction' and 'Non-fiction' - Do an item search - Filter column 'Collection', select 'Fiction' - Result: Column contains items of both collections (Fiction and Non-fiction) Similar problems can happen for other column filters of type select as well, see: jQuery DataTable ColumnFilter plugin. Can the “select” filter style support exact match? https://stackoverflow.com/questions/9520423/jquery-datatable-columnfilter-plugin-can-the-select-filter-style-support-exac
Created attachment 67883 [details] [review] 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
Created attachment 67924 [details] [review] 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>
if ( grep /^$columns[$i]$/, qw( ccode homebranch holdingbranch location notforloan ) ) { How do you know for sure that this comes from a select ? And that another value is not ? Note that we can choose to limit values by authorized values etc.
(In reply to Marcel de Rooy from comment #3) > if ( grep /^$columns[$i]$/, qw( ccode homebranch holdingbranch location > notforloan ) ) { > > How do you know for sure that this comes from a select ? And that another > value is not ? Note that we can choose to limit values by authorized values > etc. Indeed. We had this same problem. That is why I propose that all filters would be exact match in items search, SQL wildcard characters can be used to search like before : %text%. This is the way to search in items search form so I think it is logical. I will propose an alternate patch.
Created attachment 68072 [details] [review] Bug 18961: (alternate) Datatable column filters use exact match by default Datatable column filters of type select do not do an exact match. E.g. for a select with values 'Fiction' and 'Non-fiction', filtering after 'Fiction' will match both. Similar problems can happen for other column filters of type select as well, see: jQuery DataTable ColumnFilter plugin. Can the 'select' filter style support exact match? https://stackoverflow.com/questions/9520423/jquery-datatable-columnfilter-plugin-can-the-select-filter-style-support-exac This patch removes the fact that search text in colum filter behaves as 'contains', match is exact by default so that filter with select are good. For text filters, one can always use whilcards characters like in items search form. Patch adds an hint text after search results. Test plan : - Apply patch of Bug 16485 - Collection column in Item search is always empty - Make sure you have collection codes 'Fiction' and 'Non-fiction' - Do an item search - Filter column 'Collection', select 'Fiction' - Result: Column contains items of both collections (Fiction and Non-fiction) - Choose a barcode from results, for example 123456 - Search on barcode with '3' of this barcode, you get no result - Search on barcode with '%3%', you get the barcode in results
(In reply to Marcel de Rooy from comment #3) > if ( grep /^$columns[$i]$/, qw( ccode homebranch holdingbranch location > notforloan ) ) { > > How do you know for sure that this comes from a select ? And that another > value is not ? Note that we can choose to limit values by authorized values > etc. It's the column headers: https://screenshots.firefox.com/NypKJESICLDt95Vi/pro.kohadev.org I am not sure I understand this concern.
I am not sure about making this change for the text input fields as well. The truncated search behaviour is often helpful there.
(In reply to Jonathan Druart from comment #6) > (In reply to Marcel de Rooy from comment #3) > > if ( grep /^$columns[$i]$/, qw( ccode homebranch holdingbranch location > > notforloan ) ) { > > > > How do you know for sure that this comes from a select ? And that another > > value is not ? Note that we can choose to limit values by authorized values > > etc. > > It's the column headers: > https://screenshots.firefox.com/NypKJESICLDt95Vi/pro.kohadev.org > I am not sure I understand this concern. No, this is about filters passed to SearchItems.
(In reply to Katrin Fischer from comment #7) > I am not sure about making this change for the text input fields as well. > The truncated search behaviour is often helpful there. I would agree.
I suggest to push my patch and assume that only these 5 columns are linked to a AV. It's not perfect but I do not think it worth the effort.
(In reply to Jonathan Druart from comment #10) > I suggest to push my patch and assume that only these 5 columns are linked > to a AV. It's not perfect but I do not think it worth the effort. +1 Marc
Back to QA
(In reply to Jonathan Druart from comment #10) > I suggest to push my patch and assume that only these 5 columns are linked > to a AV. It's not perfect but I do not think it worth the effort. Ok, its better to have a fast solution than a long one. I'm keeping the idea in mind.
Created attachment 68258 [details] [review] 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>
Passing QA with reference to the discussion above.
Pushed to master for 17.11, thanks to everybody involved!