From: Mike Rylander Date: Fri, 8 Mar 2013 21:00:45 +0000 (-0500) Subject: move previously-universal clauses to only where they are needed X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmiker%2Fwip%2Fsearch-by-edit-date;p=evergreen%2Fequinox.git move previously-universal clauses to only where they are needed Signed-off-by: Mike Rylander --- 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';