From 60a420efd8e043439684af693ca331b023106924 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 11 Sep 2012 09:42:38 -0400 Subject: [PATCH] Fix empty statuses filter By adding a check that was overlooked. Also remove a leftover TODO note and add another test query. Signed-off-by: Thomas Berezansky Signed-off-by: Lebbeous Fogle-Weekley --- .../perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm | 3 ++- Open-ILS/src/support-scripts/test-scripts/query_tests.pl | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index de68579700..8a13776ef5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -613,7 +613,6 @@ sub toSQL { my $key = 'm.source'; $key = 'm.metarecord' if (grep {$_->name eq 'metarecord' or $_->name eq 'metabib'} @{$self->modifiers}); - #TODO: Examine how we want to do limits. And offsets. And other annoying crap like that. my $core_limit = $self->QueryParser->core_limit || 25000; my $flat_where = $$flat_plan{where}; @@ -1086,10 +1085,12 @@ sub flatten { } } case 'statuses' { + if (@{$filter->args} > 0) { $where .= $joiner if $where ne '('; $where .= "(${NOT}EXISTS(SELECT 1 FROM asset.call_number acn JOIN asset.copy acp ON acn.id = acp.call_number WHERE m.source = acn.record AND acp.circ_lib IN (SELECT * FROM search_org_list) AND NOT acn.deleted AND NOT acp.deleted AND acp.status IN (" . join(',', map { $self->QueryParser->quote_value($_) } @{ $filter->args }) . ") LIMIT 1)"; $where .= $filter->negate ? ' AND ' : ' OR '; $where .= "${NOT}EXISTS(SELECT 1 FROM biblio.peer_bib_copy_map pr JOIN asset.copy acp ON pr.target_copy = acp.id WHERE m.source = pr.peer_record AND acp.circ_lib IN (SELECT * FROM search_org_list) AND NOT acp.deleted AND acp.status IN (" . join(',', map { $self->QueryParser->quote_value($_) } @{ $filter->args }) . ") LIMIT 1))"; + } } } } diff --git a/Open-ILS/src/support-scripts/test-scripts/query_tests.pl b/Open-ILS/src/support-scripts/test-scripts/query_tests.pl index c8a2715353..042d88d6ef 100755 --- a/Open-ILS/src/support-scripts/test-scripts/query_tests.pl +++ b/Open-ILS/src/support-scripts/test-scripts/query_tests.pl @@ -26,6 +26,7 @@ my @default_queries = ( '-"keyword1"', 'keyword:"keyword1"', 'keyword:"keyword1" title:"keyword2"', + 'keyword locations() statuses()', # A small set of searches that errored out in a production install 'keyword: subject:Graphical user interfaces (Computer systems) depth(0) subject|topic[Authoring programs]', 'keyword: subject:Assassins New York (State) depth(0) subject|geographic[Buffalo (N.Y.)]', -- 2.11.0