X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRow.pm;h=60c854bd94d2e1e68fb5e656e9c65da05ec4d76a;hb=ce9f555e55e767a287831c0fcccb337cc36905de;hp=ea6ea0924df33f887f9ff9c99df543091453df45;hpb=867f1b28c4934e62ad3545c8607b2bf4c145b34a;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index ea6ea09..60c854b 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -357,9 +357,11 @@ sub insert { # this ensures we fire store_column only once # (some asshats like overriding it) if ( - (! defined $current_rowdata{$_}) + (!exists $current_rowdata{$_}) or - ( $current_rowdata{$_} ne $returned_cols->{$_}) + (defined $current_rowdata{$_} xor defined $returned_cols->{$_}) + or + (defined $current_rowdata{$_} and $current_rowdata{$_} ne $returned_cols->{$_}) ); } @@ -1137,23 +1139,38 @@ sub inflate_result { foreach my $pre (keys %{$prefetch||{}}) { - my $pre_source = $source->related_source($pre) - or $class->throw_exception("Can't prefetch non-existent relationship ${pre}"); - - my $accessor = $source->relationship_info($pre)->{attrs}{accessor} - or $class->throw_exception("No accessor for prefetched $pre"); - - my @pre_vals; + my (@pre_vals, $is_multi); if (ref $prefetch->{$pre}[0] eq 'ARRAY') { + $is_multi = 1; @pre_vals = @{$prefetch->{$pre}}; } - elsif ($accessor eq 'multi') { - $class->throw_exception("Implicit prefetch (via select/columns) not supported with accessor 'multi'"); - } else { @pre_vals = $prefetch->{$pre}; } + my $pre_source = try { + $source->related_source($pre) + } + catch { + $class->throw_exception(sprintf + + "Can't inflate manual prefetch into non-existent relationship '%s' from '%s', " + . "check the inflation specification (columns/as) ending in '%s.%s'.", + + $pre, + $source->source_name, + $pre, + (keys %{$pre_vals[0][0]})[0] || 'something.something...', + ); + }; + + my $accessor = $source->relationship_info($pre)->{attrs}{accessor} + or $class->throw_exception("No accessor type declared for prefetched $pre"); + + if (! $is_multi and $accessor eq 'multi') { + $class->throw_exception("Manual prefetch (via select/columns) not supported with accessor 'multi'"); + } + my @pre_objects; for my $me_pref (@pre_vals) {