From 6a2c17e4b7f2c23e4ce6c51862f002f5e6056520 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Thu, 22 May 2014 16:55:31 -0400 Subject: [PATCH] Fix container date source with non-unique contents It is possible for a bre container to have multiple items pointing to the same bib. In these cases, a container_date sort attempt would fail with: ERROR: more than one row returned by a subquery used as an expression This fix considers only a single date, the most recent time a given bib was added to the container. Signed-off-by: Jeff Godin --- .../perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm | 2 +- 1 file changed, 1 insertion(+), 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 2474a0df34..741862f52d 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 @@ -771,7 +771,7 @@ sub toSQL { } elsif ($sort_filter eq 'container_date' && @{$$flat_plan{container_list}}) { # Just the first container for now my $container_id = $self->QueryParser->quote_value(@{$$flat_plan{container_list}}[0]); - $rank = "FIRST((SELECT create_time FROM container.biblio_record_entry_bucket_item cbrebi WHERE cbrebi.target_biblio_record_entry = m.source AND cbrebi.bucket = " . $container_id . "))"; + $rank = "FIRST((SELECT MAX(create_time) FROM container.biblio_record_entry_bucket_item cbrebi WHERE cbrebi.target_biblio_record_entry = m.source AND cbrebi.bucket = " . $container_id . "))"; } else { # default to rel ranking $rank = $rel; -- 2.11.0