From 0e11e6eb9eb4c5cd9c65ba395fc3f9420715ebbb Mon Sep 17 00:00:00 2001 From: Alexander Hartmaier Date: Sat, 23 Oct 2010 16:41:28 +0200 Subject: [PATCH] carp if value of many-to-many pseudo rel isn't an arrayref or scalar --- lib/DBIx/Class/ResultSet/RecursiveUpdate.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm index 6626c1c..c3a1356 100644 --- a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm +++ b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm @@ -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; -- 2.45.2