From: Peter Rabbitson Date: Thu, 2 Jul 2009 22:14:09 +0000 (+0000) Subject: Apparent fix - simply delay the in_storage flagging of the main object until all... X-Git-Tag: v0.08108~18^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=35c77aa30e6a2b21a81b945adbbbb9599d6828fa;p=dbsrgits%2FDBIx-Class.git Apparent fix - simply delay the in_storage flagging of the main object until all prefetched objects are inflated. The rest of the changes are just cosmetics, preparing for the collapse_result rewrite --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index d89bf60..3b318a4 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1193,7 +1193,6 @@ our $UNRESOLVABLE_CONDITION = \'1 = 0'; sub _resolve_condition { my ($self, $cond, $as, $for) = @_; - #warn %$cond; if (ref $cond eq 'HASH') { my %ret; foreach my $k (keys %{$cond}) { @@ -1234,7 +1233,7 @@ sub _resolve_condition { } elsif (ref $cond eq 'ARRAY') { return [ map { $self->_resolve_condition($_, $as, $for) } @$cond ]; } else { - die("Can't handle this yet :("); + die("Can't handle condition $cond yet :("); } } diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index f1e4846..f5b5026 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -1053,7 +1053,6 @@ sub inflate_result { my $new = { _source_handle => $source_handle, _column_data => $me, - _in_storage => 1 }; bless $new, (ref $class || $class); @@ -1065,14 +1064,25 @@ sub inflate_result { unless $pre_source; if (ref($pre_val->[0]) eq 'ARRAY') { # multi my @pre_objects; - foreach my $pre_rec (@$pre_val) { - unless ($pre_source->primary_columns == grep { exists $pre_rec->[0]{$_} - and defined $pre_rec->[0]{$_} } $pre_source->primary_columns) { - next; + + for my $me_pref (@$pre_val) { + + # the collapser currently *could* return bogus elements with all + # columns set to undef + my $has_def; + for (values %{$me_pref->[0]}) { + if (defined $_) { + $has_def++; + last; + } } - push(@pre_objects, $pre_source->result_class->inflate_result( - $pre_source, @{$pre_rec})); + next unless $has_def; + + push @pre_objects, $pre_source->result_class->inflate_result( + $pre_source, @$me_pref + ); } + $new->related_resultset($pre)->set_cache(\@pre_objects); } elsif (defined $pre_val->[0]) { my $fetched; @@ -1095,6 +1105,8 @@ sub inflate_result { $new->related_resultset($pre)->set_cache([ $fetched ]); } } + + $new->in_storage (1); return $new; }