Flattener stores might_have links as arrays
authorBill Erickson <berick@esilibrary.com>
Mon, 26 Mar 2012 13:56:58 +0000 (09:56 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 26 Mar 2012 13:56:58 +0000 (09:56 -0400)
E.g. "aou", {"addrs" : "addresses.id"}

{ "addrs" : [ 1,2,3 ] }

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Flattener.pm

index 09e20b1..73d73be 100644 (file)
@@ -371,7 +371,12 @@ sub process_result {
             last unless ref $obj;
         }
 
-        $flatrow->{$key} = ref $obj ? $obj->$field : undef;
+        if (ref $obj eq 'ARRAY') {
+            # might_have links return arrays
+            $flatrow->{$key} = [ map {$_->$field} @$obj ];
+        } else {
+            $flatrow->{$key} = ref $obj ? $obj->$field : undef;
+        }
     }
 
     return $flatrow;