From 730a9071ba6ba6e30450c4e650b7afbdd17f6940 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 19 Oct 2011 13:42:16 -0400 Subject: [PATCH] CStoreEditor batch_retrieve repairs 1. If the caller provides additional cstore params, like flesh, flesh_fields, etc. make sure we only use the first component of the search (the list of identifier values) for the cstore search. 2. Determine the identifier field from the class being retrieved instead of hard-coding it to be "id" Signed-off-by: Bill Erickson --- Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm index 48c6e39f17..1b11bd92e1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm @@ -696,9 +696,20 @@ sub runmethod { } elsif( $action eq 'batch_retrieve' ) { $action = 'search'; - @arg = ( { id => $arg } ); $method =~ s/batch_retrieve/search/o; $method .= '.atomic'; + my $tt = $type; + $tt =~ s/\./::/og; + my $fmobj = "Fieldmapper::$tt"; + my $ident_field = $fmobj->Identity; + + if (ref $arg[0] eq 'ARRAY') { + # $arg looks like: [[1, 2, 3], {search_args}] + @arg = ( { $ident_field => $arg[0] } ); + } else { + # $arg looks like: [1, 2, 3] + @arg = ( { $ident_field => $arg } ); + } } elsif( $action eq 'retrieve_all' ) { $action = 'search'; -- 2.11.0