Bugzilla – Attachment 22769 Details for
Bug 10855
Custom fields for subscriptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10855: A partial search should return the subscriptions
Bug-10855-A-partial-search-should-return-the-subsc.patch (text/plain), 3.54 KB, created by
Jonathan Druart
on 2013-11-07 12:42:11 UTC
(
hide
)
Description:
Bug 10855: A partial search should return the subscriptions
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-11-07 12:42:11 UTC
Size:
3.54 KB
patch
obsolete
>From fffd006ab1176bb969926734a30575f913575394 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 7 Nov 2013 12:33:37 +0100 >Subject: [PATCH] Bug 10855: A partial search should return the subscriptions > >If a search on an additional fields is done using a partial string >("foo" and the defined value is "foobar"), the subscription should >appear in the result list. > >Test plan: >Try to search a part of the string for an additional field. >--- > C4/Serials.pm | 1 + > Koha/AdditionalField.pm | 5 +++-- > t/db_dependent/AdditionalField.t | 17 ++++++++++++++++- > 3 files changed, 20 insertions(+), 3 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 4de2b65..1ef8413 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -657,6 +657,7 @@ sub SearchSubscriptions { > $matching_record_ids_for_additional_fields = Koha::AdditionalField->get_matching_record_ids({ > fields => $args->{additional_fields}, > tablename => 'subscription', >+ exact_match => 0, > }); > return () unless @$matching_record_ids_for_additional_fields; > } >diff --git a/Koha/AdditionalField.pm b/Koha/AdditionalField.pm >index 4b38a45..fe45b18 100644 >--- a/Koha/AdditionalField.pm >+++ b/Koha/AdditionalField.pm >@@ -204,6 +204,7 @@ sub get_matching_record_ids { > > my $fields = $args->{fields} // []; > my $tablename = $args->{tablename}; >+ my $exact_match = $args->{exact_match} // 1; > return [] unless @$fields; > > my $dbh = C4::Context->dbh; >@@ -222,13 +223,13 @@ sub get_matching_record_ids { > WHERE afv.field_id = af.id > AND af.name = ? > AND af.tablename = ? >- AND value = ? >+ AND value LIKE ? > ) AS field$i USING (id) > WHERE field$i.id IS NOT NULL > ) AS values$i |; > $subquery .= ' USING (record_id)' if $i > 1; > push @subqueries, $subquery; >- push @args, $field->{name}, $tablename, $field->{value}; >+ push @args, $field->{name}, $tablename, ( $exact_match ? $field->{value} : "%$field->{value}%" ); > } > $query .= join( ' LEFT JOIN ', @subqueries ) . ' WHERE 1'; > for my $j ( 1 .. $i ) { >diff --git a/t/db_dependent/AdditionalField.t b/t/db_dependent/AdditionalField.t >index 861c15a..df307a4 100644 >--- a/t/db_dependent/AdditionalField.t >+++ b/t/db_dependent/AdditionalField.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 34; >+use Test::More tests => 37; > > use C4::Context; > use Koha::AdditionalField; >@@ -276,4 +276,19 @@ is ( $exists, 1, "get_matching_record_ids: field common: common_value matches su > $exists = grep /not_existent_id/, @$matching_record_ids; > is ( $exists, 0, "get_matching_record_ids: field common: common_value does not inexistent id" ); > >+$fields = [ >+ { >+ name => 'common', >+ value => q|common|, >+ } >+]; >+$matching_record_ids = Koha::AdditionalField->get_matching_record_ids({ tablename => 'subscription', fields => $fields, exact_match => 0 }); >+$exists = grep /$subscriptionid1/, @$matching_record_ids; >+is ( $exists, 1, "get_matching_record_ids: field common: common% matches subscription1" ); >+$exists = grep /$subscriptionid2/, @$matching_record_ids; >+is ( $exists, 1, "get_matching_record_ids: field common: common% matches subscription2 too" ); >+$exists = grep /not_existent_id/, @$matching_record_ids; >+is ( $exists, 0, "get_matching_record_ids: field common: common% does not inexistent id" ); >+ >+ > $dbh->rollback; >-- >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 10855
:
20937
|
20938
|
20939
|
20940
|
20941
|
20942
|
20943
|
20944
|
21184
|
21185
|
21186
|
21187
|
21188
|
21189
|
21190
|
21191
|
21663
|
22049
|
22050
|
22051
|
22052
|
22053
|
22054
|
22055
|
22056
|
22057
|
22359
|
22360
|
22600
|
22601
|
22602
|
22603
|
22604
|
22605
|
22606
|
22607
|
22608
|
22616
|
22698
|
22699
|
22700
|
22701
|
22702
|
22703
|
22722
|
22768
|
22769
|
22869
|
23052
|
23053
|
23142
|
23143
|
23301
|
23302
|
23594
|
23595
|
23596
|
23597
|
23598
|
23599
|
23600
|
23601
|
23602
|
23774
|
23775
|
23961
|
23962
|
23963
|
23964
|
24452
|
24453
|
24454
|
24455
|
24456
|
24457
|
24569
|
24570
|
26091
|
26092
|
26093
|
26094
|
26095
|
26096
|
26097
|
26254
|
26255
|
26256
|
26257
|
26258
|
26259
|
26260
|
26276
|
26651
|
26655
|
28929
|
28930
|
28931
|
28932
|
28933
|
28934
|
28935
|
28936
|
28937
|
28938
|
28939
|
28940
|
28941
|
29095
|
29161
|
35211
|
35212
|
35213
|
35214
|
35215
|
35216
|
35217
|
35218
|
35219
|
35220
|
35221
|
35309
|
35310
|
35369
|
35556
|
36359
|
36362
|
36363
|
36364
|
36365
|
36366
|
36367
|
36368
|
36369
|
36370
|
36371
|
36372
|
36373
|
36374
|
38549
|
38550
|
38551
|
38552
|
38553
|
38554
|
38555
|
38556
|
38557
|
38558
|
38559
|
38560
|
38561
|
42296
|
42297
|
42298
|
42299
|
42300
|
42301
|
42302
|
42303
|
42304
|
42305
|
42306
|
42307
|
42308
|
42309
|
42310
|
42332
|
42333
|
43076