diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 06d0e86c7f..5bf369cd6a 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -595,12 +595,12 @@ sub get_components_query { if ( !defined($pf003) ) { # search for 773$w='Host001' - $searchstr .= "rcn:" . $pf001->data(); + $searchstr .= "rcn:\"" . $pf001->data()."\""; } else { $searchstr .= "("; # search for (773$w='Host001' and 003='Host003') or 773$w='(Host003)Host001' - $searchstr .= "(rcn:" . $pf001->data() . " AND cni:" . $pf003->data() . ")"; + $searchstr .= "(rcn:\"" . $pf001->data() . "\" AND cni:\"" . $pf003->data() . "\")"; $searchstr .= " OR rcn:\"" . $pf003->data() . " " . $pf001->data() . "\""; $searchstr .= ")"; } diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index ac9fcd0466..67513cd09f 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -586,7 +586,7 @@ subtest 'get_components_query' => sub { $biblio = Koha::Biblios->find( $biblio->biblionumber); ( $comp_query, $comp_query_str, $comp_sort ) = $biblio->get_components_query; - is($comp_query_str, "(rcn:$biblionumber AND (bib-level:a OR bib-level:b))", "$engine: UseControlNumber enabled without MarcOrgCode"); + is($comp_query_str, "(rcn:\"$biblionumber\" AND (bib-level:a OR bib-level:b))", "$engine: UseControlNumber enabled without MarcOrgCode"); is($comp_sort, "author_az", "$engine: UseControlNumber enabled without MarcOrgCode sort is correct"); my $marc_003_field = MARC::Field->new('003', 'OSt'); @@ -597,7 +597,7 @@ subtest 'get_components_query' => sub { t::lib::Mocks::mock_preference( 'ComponentSortField', 'title' ); t::lib::Mocks::mock_preference( 'ComponentSortOrder', 'asc' ); ( $comp_query, $comp_query_str, $comp_sort ) = $biblio->get_components_query; - is($comp_query_str, "(((rcn:$biblionumber AND cni:OSt) OR rcn:\"OSt $biblionumber\") AND (bib-level:a OR bib-level:b))", "$engine: UseControlNumber enabled with MarcOrgCode"); + is($comp_query_str, "(((rcn:\"$biblionumber\" AND cni:\"OSt\") OR rcn:\"OSt $biblionumber\") AND (bib-level:a OR bib-level:b))", "$engine: UseControlNumber enabled with MarcOrgCode"); is($comp_sort, "title_asc", "$engine: UseControlNumber enabled with MarcOrgCode sort if correct"); $record->delete_field($marc_003_field); }