From cd333b369839f4f92988c7198c4098d8d16fdc0b 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 f87260c4a7..ad1cc3a338 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 @@ -921,6 +921,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"; @@ -938,9 +949,6 @@ sub toSQL { AND pr.peer_record = m.source LIMIT 1 ) - SQL - } - $limit_where .= <<" SQL"; OR EXISTS( SELECT 1 FROM asset.call_number acn @@ -952,8 +960,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