From c17da8be5a7145e7a1e90bde18553e3d7f125cc4 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 15 May 2020 17:42:53 -0400 Subject: [PATCH] allow __fuzzy to override au_by_id in unified search Signed-off-by: Galen Charlton --- .../src/perlmods/lib/OpenILS/Application/Acq/Search.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm index 35965feeaf..dcdc20b460 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm @@ -260,7 +260,7 @@ sub gen_au_term { # actor.usr.id but by any of these user properties: card barcode, username, # given names and family name. sub prepare_au_terms { - my ($terms, $join_num) = @_; + my ($terms, $join_num, $default_to_by_id) = @_; my @joins = (); my $nots = 0; @@ -283,8 +283,10 @@ sub prepare_au_terms { $plain_hint ne "acqlia") { my @new_terms = (); my ($attr, $value) = breakdown_term($hint_unit->{$hint}); + my $is_fuzzy = ref($value) eq 'HASH' && exists($value->{'ilike'}); if ($links->{$attr} and - $links->{$attr}->{"class"} eq "au") { + $links->{$attr}->{"class"} eq "au" and + not($default_to_by_id and not $is_fuzzy)) { push @joins, [$plain_hint, $attr, $join_num]; my $au_term = gen_au_term($value, $join_num); if ($nots > 0) { @@ -685,12 +687,10 @@ sub unified_search { $and_terms = prepare_terms($and_terms, 1); $or_terms = prepare_terms($or_terms, 0); - unless ($options->{au_by_id}) { - my $offset = add_au_joins($graft_map, $hint, prepare_au_terms($and_terms)); - add_au_joins($graft_map, $hint, prepare_au_terms($or_terms, $offset)); - } + my $offset = add_au_joins($graft_map, $hint, prepare_au_terms($and_terms, 0, $options->{au_by_id})); + add_au_joins($graft_map, $hint, prepare_au_terms($or_terms, $offset, $options->{au_by_id})); - my $offset = add_acqpro_joins($graft_map, $hint, prepare_acqpro_terms($and_terms)); + $offset = add_acqpro_joins($graft_map, $hint, prepare_acqpro_terms($and_terms)); add_acqpro_joins($graft_map, $hint, prepare_acqpro_terms($or_terms, $offset)); # The join to acqmapinv needs to be a left join when present. -- 2.11.0