X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet%2FRecursiveUpdate.pm;h=c3a1356047ce1984751a8eb861ddbb6df17bfe63;hb=0e11e6eb9eb4c5cd9c65ba395fc3f9420715ebbb;hp=59dbc47311d5368778107044ec6eddd81e3a1250;hpb=796be7d1efe8f69366f756021d86a427c222a5c3;p=chaz%2Fp5-DBIx-Class-ResultSet-RecursiveUpdate diff --git a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm index 59dbc47..c3a1356 100644 --- a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm +++ b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm @@ -50,7 +50,7 @@ sub recursive_update { my $source = $self->result_source; # warn 'entering: ' . $source->from(); - carp 'fixed fields needs to be an array ref' + croak 'fixed fields needs to be an arrayref' if defined $fixed_fields && ref $fixed_fields ne 'ARRAY'; if ( blessed($updates) && $updates->isa('DBIx::Class::Row') ) { @@ -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;