[Bug 19873] New: Make it possible to search on value 0
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Bug ID: 19873 Summary: Make it possible to search on value 0 Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Searching Assignee: koha-bugs@lists.koha-community.org Reporter: gaetan.boisson@biblibre.com QA Contact: testopia@bugs.koha-community.org The current code considers a value of 0 in a search query as an empty string, that is, it won't search on it. If a library wants to search for records that specifically have the value "0" in a given field, it will not be possible. This patch aims to correct this. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #1 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 70122 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=70122&action=edit Bug 19873 - Ability to search on 0 value Test plan: - create a st-numeric index in zebra conf related to a numeric field i.e: yourindex 1=yourindex 4=109 - fill a field with 0 in a biblio, - reindex your biblios, - search yourindex=0, - should not work, - apply this patch, - test again, - should work -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff CC| |alex.arnaud@biblibre.com -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |alex.arnaud@biblibre.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #2 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- + original_operand => ($operands[$i] ne '') ? $operands[$i] : '', I think it could be more pretty : + original_operand => $operands[$i] // '', -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #3 from M. Tompsett <mtompset@hotmail.com> --- Comment on attachment 70122 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=70122 Bug 19873 - Ability to search on 0 value Review of attachment 70122: --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=19873&attachment=70122) ----------------------------------------------------------------- ::: C4/Search.pm @@ +1532,4 @@
for ( my $i = 0 ; $i <= @operands ; $i++ ) {
# COMBINE OPERANDS, INDEXES AND OPERATORS + if ( $operands[$i] ne '' ) {
perhaps a $operands[$i] // q{} ne q{} would be in order. We don't want floody logs if $operands[$i] is undef. @@ +1677,4 @@
query_desc => $query_desc, operator => ($operators[ $i - 1 ]) ? $operators[ $i - 1 ] : '', parsed_operand => $operand, + original_operand => ($operands[$i] ne '') ? $operands[$i] : '',
perhaps a $operands[$i] // q{} is sufficient? We don't want floody logs if $operands[$i] is undef. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #4 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to M. Tompsett from comment #3)
Comment on attachment 70122 [details] [review] Bug 19873 - Ability to search on 0 value
Review of attachment 70122 [details] [review]: -----------------------------------------------------------------
::: C4/Search.pm @@ +1532,4 @@
for ( my $i = 0 ; $i <= @operands ; $i++ ) {
# COMBINE OPERANDS, INDEXES AND OPERATORS + if ( $operands[$i] ne '' ) {
perhaps a $operands[$i] // q{} ne q{} would be in order. We don't want floody logs if $operands[$i] is undef.
@@ +1677,4 @@
query_desc => $query_desc, operator => ($operators[ $i - 1 ]) ? $operators[ $i - 1 ] : '', parsed_operand => $operand, + original_operand => ($operands[$i] ne '') ? $operands[$i] : '',
perhaps a $operands[$i] // q{} is sufficient? We don't want floody logs if $operands[$i] is undef.
We want to search on 0 value. And $operands[$i] // q{} is false if $operands[$i] equals 0: (0 ne '') => 1 (0 // '') => 0 (0 // q{}) => 0 (0 ne q{}) => 0 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org --- Comment #5 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Provide tests please. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #6 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 72307 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=72307&action=edit Bug 19873 - Add unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Brendan Gallagher <brendan@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Brendan Gallagher <brendan@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #70122|0 |1 is obsolete| | --- Comment #7 from Brendan Gallagher <brendan@bywatersolutions.com> --- Created attachment 72839 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=72839&action=edit Bug 19873 - Ability to search on 0 value Test plan: - create a st-numeric index in zebra conf related to a numeric field i.e: yourindex 1=yourindex 4=109 - fill a field with 0 in a biblio, - reindex your biblios, - search yourindex=0, - should not work, - apply this patch, - test again, - should work Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Brendan Gallagher <brendan@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #72307|0 |1 is obsolete| | --- Comment #8 from Brendan Gallagher <brendan@bywatersolutions.com> --- Created attachment 72840 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=72840&action=edit Bug 19873 - Add unit tests Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |julian.maurice@biblibre.com |y.org | CC| |julian.maurice@biblibre.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #9 from Julian Maurice <julian.maurice@biblibre.com> --- (In reply to Alex Arnaud from comment #4)
(In reply to M. Tompsett from comment #3)
Comment on attachment 70122 [details] [review] [review] Bug 19873 - Ability to search on 0 value
Review of attachment 70122 [details] [review] [review]: -----------------------------------------------------------------
::: C4/Search.pm @@ +1532,4 @@
for ( my $i = 0 ; $i <= @operands ; $i++ ) {
# COMBINE OPERANDS, INDEXES AND OPERATORS + if ( $operands[$i] ne '' ) {
perhaps a $operands[$i] // q{} ne q{} would be in order. We don't want floody logs if $operands[$i] is undef.
@@ +1677,4 @@
query_desc => $query_desc, operator => ($operators[ $i - 1 ]) ? $operators[ $i - 1 ] : '', parsed_operand => $operand, + original_operand => ($operands[$i] ne '') ? $operands[$i] : '',
perhaps a $operands[$i] // q{} is sufficient? We don't want floody logs if $operands[$i] is undef.
We want to search on 0 value. And $operands[$i] // q{} is false if $operands[$i] equals 0:
(0 ne '') => 1 (0 // '') => 0 (0 // q{}) => 0 (0 ne q{}) => 0
True but I think that what Mark suggested is to replace "if" condition by ($operands[$i] // '') ne '' # I don't like "q{}" string for empty strings :) which is true when $operands[$i] == 0, and doesn't generate a warning when undef and the other change by $operands[$i] // '' which has the same behaviour, with the additional benefit of preventing warnings I will provide a follow-up after testing -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #10 from Julian Maurice <julian.maurice@biblibre.com> --- I'm not sure how to do:
- search yourindex=0 If I type this in the search form, it searches for "kw,wrdl: yourindex=0", unless I add 'yourindex' in C4::Search::getIndexes, in which case it searches for 'yourindex: 0', and this search works without the patch.
Can you explain what I'm doing wrong ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #11 from Julian Maurice <julian.maurice@biblibre.com> --- (In reply to Julian Maurice from comment #10)
I'm not sure how to do:
- search yourindex=0 If I type this in the search form, it searches for "kw,wrdl: yourindex=0", unless I add 'yourindex' in C4::Search::getIndexes, in which case it searches for 'yourindex: 0', and this search works without the patch.
Can you explain what I'm doing wrong ? Ok, I had to do a query like this:
http://pro.master.koha-dev/cgi-bin/koha/catalogue/search.pl?idx=yourindex&q=0 to trigger the bug. The patch fixes this. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #12 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 74622 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=74622&action=edit Bug 19873: Ability to search on 0 value Test plan: - create a st-numeric index in zebra conf related to a numeric field i.e: yourindex 1=yourindex 4=109 - fill a field with 0 in a biblio, - reindex your biblios, - search yourindex=0, - should not work, - apply this patch, - test again, - should work Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #13 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 74623 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=74623&action=edit Bug 19873: Add unit tests Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #14 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 74624 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=74624&action=edit Bug 19873: (QA follow-up) Prevent warnings "Use of uninitialized value $operands[X] in string ne" Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #72839|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #72840|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #15 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Pushed to master for 18.05, thanks to everybody involved! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |Pushed to Stable CC| |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 --- Comment #16 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Pushed to 17.11.x for 17.11.08 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|Pushed to Stable |RESOLVED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19873 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |28365 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28365 [Bug 28365] (Bug 19873 follow-up) Make it possible to search on value 0 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org