]> Dogcows Code - chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate/commitdiff
hashrefs in m2m
authorzby <zby@bd8105ee-0ff8-0310-8827-fb3f25b6796d>
Thu, 13 Nov 2008 08:12:38 +0000 (08:12 +0000)
committerzby <zby@bd8105ee-0ff8-0310-8827-fb3f25b6796d>
Thu, 13 Nov 2008 08:12:38 +0000 (08:12 +0000)
lib/DBIx/Class/ResultSet/RecursiveUpdate.pm
t/lib/RunTests.pm
t/var/dvdzbr.db

index 39366e714674d98aa619de482be6f46e0aa83662..2dc40cba4f7ba698cddb0b5befa90d60a1420249 100644 (file)
@@ -55,10 +55,16 @@ sub recursive_update {
         # many to many case
         if( $self->is_m2m( $name ) ) {
                 my ( $pk ) = $self->_get_pk_for_related( $name );
-                my @values = @{$updates->{$name}};
                 my @rows;
                 my $result_source = $object->$name->result_source;
-                @rows = $result_source->resultset->search({ $pk => [ @values ] } ) if @values; 
+                for my $elem ( @{$updates->{$name}} ){
+                    if( ref $elem ){
+                        push @rows, $result_source->resultset->find( $elem );
+                    }
+                    else{
+                        push @rows, $result_source->resultset->find( { $pk => $elem } );
+                    }
+                }
                 my $set_meth = 'set_' . $name;
                 $object->$set_meth( \@rows );
         }
index e38d1f1d7d4c485a8d02300d491724d59bcd245c..f3bfbb121bffec700076f19b0121b56246baf17b 100644 (file)
@@ -18,7 +18,7 @@ sub run_tests{
     my $updates = {
             id => undef,
             aaaa => undef,
-            tags => [ '2', '3' ], 
+            tags => [ '2', { id => '3' } ], 
             name => 'Test name',
     #        'creation_date.year' => 2002,
     #        'creation_date.month' => 1,
index 86a55809d2fd6e8490bc3e06e1cd7a657d15e317..1aad3b8639d1fc2c0e4101420ab2033122e63c01 100644 (file)
Binary files a/t/var/dvdzbr.db and b/t/var/dvdzbr.db differ
This page took 0.027818 seconds and 4 git commands to generate.