Bugzilla – Attachment 45131 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.63 KB, created by
Fridolin Somers
on 2015-11-25 12:12:04 UTC
(
hide
)
Description:
Bug 15252 - Patron search on start with does not work with several terms
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2015-11-25 12:12:04 UTC
Size:
3.63 KB
patch
obsolete
>From d49722b15a6b90a2611ce5272c46c1d4f06e8ed6 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 > >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" >--- > C4/Utils/DataTables/Members.pm | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > >diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm >index bfa73e0..9628b1e 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,27 @@ sub search { > sort1 => 'sort1', > sort2 => 'sort2', > }; >- foreach my $term ( split / /, $searchmember) { >+ >+ # 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 =~ 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 ?"; >-- >2.1.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