Bugzilla – Attachment 45735 Details for
Bug 15252
Patron search on start with does not work with several terms
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15252 - Patron search on start with does not work with several terms
Bug-15252---Patron-search-on-start-with-does-not-w.patch (text/plain), 3.87 KB, created by
Marc Véron
on 2015-12-16 17:42:01 UTC
(
hide
)
Description:
Bug 15252 - Patron search on start with does not work with several terms
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-12-16 17:42:01 UTC
Size:
3.87 KB
patch
obsolete
>From 0d80e2f6b0a4669a6b7b5e7de8d13dec94584a33 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Wed, 25 Nov 2015 12:34:18 +0100 >Subject: [PATCH] Bug 15252 - Patron search on start with does not work with > several terms >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When searching a patron, search type can be 'start with' and 'contain'. >If the search text contains a space (or a coma), this text is splitted into several terms. > >Actually, the search on 'start with' with several terms never returns a result. > >It is because the search composes an "AND" SQL query on terms. >For example (I display only the surname part) : >search type = contain : > 'jean paul' => surname like '%jean% AND %paul%' >search type = start with : > 'jean paul' => surname like 'jean% AND paul%' >The query for 'start with' is impossible. > >I propose, for search with start with, to not split terms : > jean paul => surname like 'jean paul%' > >One can always use '*' to add more truncation : > jea* pau* => surname like 'jea% pau%' > >This bug affects a lot surnames with several terms like 'LE GUELEC' or 'MAC BETH'. > >Note that the patch moves : > $searchmember =~ s/,/ /g; >It removes the test "if $searchmember" because $searchmember is tested and set to empty string previously : > unless ( $searchmember ) { > $searchmember = $dt_params->{sSearch} // ''; > } > >Test plan : >========== >- Create two patrons with firstname "Jean Paul" >- Go to Patrons module >- Choose "Starts with" in "Search type" filter >- Perform a search on "Jean Paul" >=> without patch : you get no result >=> with this patch : you get the two results >- Check you get the two results for search on "Jean Pau" >- Check you get the two results for search on "Jea* Pau*" >- Check you do not get results for search on "Jea Paul" >- Choose "Contains" in "Search type" filter >- Check you get the two results for search on "Jean Paul" >- Check you get the two results for search on "Jean Pau" >- Check you get the two results for search on "Jea* Pau*" >- Check you get the two results for search on "Jea Paul" >- Check you get the two results for search on "Paul Jean" > >Signed-off-by: Alex <alexklbuckley@gmail.com> > >Tested 4 patches together, works as expected >Signed-off-by: Marc Véron <veron@veron.ch> >--- > C4/Utils/DataTables/Members.pm | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > >diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm >index bfa73e0..31af767 100644 >--- a/C4/Utils/DataTables/Members.pm >+++ b/C4/Utils/DataTables/Members.pm >@@ -59,8 +59,6 @@ sub search { > push @where_args, $branchcode; > } > >- # split on coma >- $searchmember =~ s/,/ /g if $searchmember; > my $searchfields = { > standard => 'surname,firstname,othernames,cardnumber,userid', > email => 'email,emailpro,B_email', >@@ -72,14 +70,29 @@ sub search { > sort1 => 'sort1', > sort2 => 'sort2', > }; >- foreach my $term ( split / /, $searchmember) { >+ >+ # * is replaced with % for sql >+ $searchmember =~ s/\*/%/g; >+ >+ # split into search terms >+ my @terms; >+ # consider coma as space >+ $searchmember =~ s/,/ /g; >+ if ( $searchtype eq 'contain' ) { >+ @terms = split / /, $searchmember; >+ } else { >+ @terms = ($searchmember); >+ } >+ >+ foreach my $term (@terms) { > next unless $term; >- $searchmember =~ s/\*/%/g; # * is replaced with % for sql >+ > $term .= '%' # end with anything > if $term !~ /%$/; > $term = "%$term" # begin with anythin unless start_with > if (defined $searchtype) && $searchtype eq "contain" > && $term !~ /^%/; >+ > my @where_strs_or; > for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) { > push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15252
:
45131
|
45132
|
45133
|
45134
|
45300
|
45301
|
45302
|
45303
|
45390
|
45391
|
45392
|
45393
|
45395
|
45401
|
45403
|
45405
|
45406
|
45407
|
45735
|
45736
|
45737
|
45738
|
45830
|
45831