carp if value of many-to-many pseudo rel isn't an arrayref or scalar
authorAlexander Hartmaier <abraxxa@cpan.org>
Sat, 23 Oct 2010 14:41:28 +0000 (16:41 +0200)
committerAlexander Hartmaier <abraxxa@cpan.org>
Sat, 23 Oct 2010 14:41:28 +0000 (16:41 +0200)
lib/DBIx/Class/ResultSet/RecursiveUpdate.pm

index 6626c1c9145b66eb110810baafa722e32314559b..c3a1356047ce1984751a8eb861ddbb6df17bfe63 100644 (file)
@@ -197,19 +197,18 @@ sub recursive_update {
         #warn "update m2m $name\n";
         # TODO: only first pk col is used
         my ($pk) = _get_pk_for_related( $self, $name );
-        my @rows;
+        my @rows = ();
         my $result_source = $object->$name->result_source;
         my @updates;
-        if ( !defined $value ) {
-            #next;
-            @updates = ();
-        }
-        elsif ( ref $value ) {
+        if ( defined $value && ref $value eq 'ARRAY' ) {
             @updates = @{$value};
         }
-        else {
+        elsif ( defined $value && !ref $value ) {
             @updates = ($value);
         }
+        else {
+            carp "value of many-to-many rel '$name' must be an arrayref or scalar";
+        }
         for my $elem (@updates) {
             if ( ref $elem ) {
                 push @rows, $elem;
This page took 0.020566 seconds and 4 git commands to generate.