From 7947dd6ee9711102d5fb3fc579316d830d610da1 Mon Sep 17 00:00:00 2001 From: zby Date: Thu, 13 Nov 2008 08:12:38 +0000 Subject: [PATCH] hashrefs in m2m --- lib/DBIx/Class/ResultSet/RecursiveUpdate.pm | 10 ++++++++-- t/lib/RunTests.pm | 2 +- t/var/dvdzbr.db | Bin 26624 -> 26624 bytes 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm index 39366e7..2dc40cb 100644 --- a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm +++ b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm @@ -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 ); } diff --git a/t/lib/RunTests.pm b/t/lib/RunTests.pm index e38d1f1..f3bfbb1 100644 --- a/t/lib/RunTests.pm +++ b/t/lib/RunTests.pm @@ -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, diff --git a/t/var/dvdzbr.db b/t/var/dvdzbr.db index 86a55809d2fd6e8490bc3e06e1cd7a657d15e317..1aad3b8639d1fc2c0e4101420ab2033122e63c01 100644 GIT binary patch delta 621 zcmZuv%}*0i5a0LF?zR*x3w28ac5TbHr3q=z0TVn~FjlxjCxY+7v#Au$ow zlkuRIxfpMLaPcI&o;-1S7ZTII01sX~nn0py2>PUv^x(_<@@D2Y^FC%~qlq?}=w(1Q zB0_r&@Xa9zDY>CfNSGY__4>9SJS7r~bJfklZ>ePYos#YBKO#0w9TH2W^c{^+SroPe zVGCWyZjQTb*M*;=+szw-NJ}6syZ7b~0?msQ zI~>*&l{^$L3V0EJCxhhqwwc9YUW*Y?2?mjQhy<&UfxPxi??FoGl-=e7K)9 z%Ab_>Nl4NZCHvkzKBfciwYs6_H}9e@3bO1JBMq)MhV^DI=N=C+-BbI2Vy~`TQY5~^ zM|PP##w1?EC$5vHr$=8fF+_96c9_V~sF?vy%jS6|^0aNHpo89;Stbhf!;FJQed&@a zPN=c*1o`E-v2<%`qqIDqZ?irlhUr<_gl>A5F5rw9p{QlTA$f~a#_FW&R=9bXbE#!Q zQC`6X@YoUN<1F4&CS0e0HBltj&eIjUpLXm4?x^A<)vW>OqKDQZu8LE1JG&MYr?ps5 z4>-k*Qn^}@0we