From d0997d8aa1b41cdc29cdbed82388fddef9ab8c62 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 8 Mar 2013 16:00:45 -0500 Subject: [PATCH] move previously-universal clauses to only where they are needed Signed-off-by: Mike Rylander --- .../Application/Storage/Driver/Pg/QueryParser.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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 18543b6ede..014f5db83d 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 @@ -924,6 +924,17 @@ sub toSQL { LIMIT 1 ) ) + OR + EXISTS( + SELECT 1 FROM asset.call_number acn + JOIN asset.uri_call_number_map aucnm ON acn.id = aucnm.call_number + JOIN asset.uri uri ON aucnm.uri = uri.id + WHERE NOT acn.deleted AND uri.active AND acn.record = m.source AND acn.owning_lib IN ( + SELECT * FROM luri_org_list + ) + LIMIT 1 + ) + ) SQL } else { $limit_where .= <<" SQL"; @@ -941,9 +952,6 @@ sub toSQL { AND pr.peer_record = m.source LIMIT 1 ) - SQL - } - $limit_where .= <<" SQL"; OR EXISTS( SELECT 1 FROM asset.call_number acn @@ -955,8 +963,8 @@ sub toSQL { LIMIT 1 ) ) - SQL - + SQL + } # For single records we want the record id # For metarecords we want NULL or the only record ID. my $agg_record = 'm.source AS record'; -- 2.11.0