From a872403007022d89c0627c5d24b8557dcb49c7c7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 19 Jul 2012 17:23:10 -0400 Subject: [PATCH] acq search : support acqlisum and gte/lte on non-date fields Signed-off-by: Bill Erickson --- Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 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 fce6604cf7..e1813038b2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm @@ -229,7 +229,7 @@ sub prepare_terms { my $conj = $is_and ? "-and" : "-or"; my $outer_clause = {}; - foreach my $class (qw/acqpo acqpl acqinv jub acqlid/) { + foreach my $class (qw/acqpo acqpl acqinv jub acqlid acqlisum/) { next if not exists $terms->{$class}; $outer_clause->{$conj} = [] unless $outer_clause->{$conj}; @@ -243,7 +243,12 @@ sub prepare_terms { } elsif ($between and could_be_range($v)) { $term_clause = {$k => {"between" => $v}}; } elsif (check_1d_max($v)) { - $v = castdate($v, $gte, $lte) if $castdate; + if ($castdate) { + $v = castdate($v, $gte, $lte) if $castdate; + } elsif ($gte or $lte) { + my $op = $gte ? '>=' : '<='; + $v = {$op => $v}; + } $term_clause = {$k => $v}; } else { next; @@ -339,6 +344,10 @@ sub build_from_clause_and_joins { } else { $graft_map{$class} = $query->{from}{$core}{$class} ||= {}; $graft_map{$class}{type} = $join_type; + + # without this, the SQL attempts to join on + # jub.order_summary, which is a virtual field. + $graft_map{$class}{field} = 'lineitem' if $class eq 'acqlisum'; } } -- 2.11.0