Revision history for DBIx::Class
+ - Fixed regression when both page and offset are specified on
+ a resultset
+ - Fixed HRI returning too many empty results on multilevel
+ nonexisting prefetch
+
0.08107 2009-06-14 08:21:00 (UTC)
- Fix serialization regression introduced in 0.08103 (affects
Cursor::Cached)
# if there is at least one defined column consider the resultset real
# (and not an emtpy has_many rel containing one empty hashref)
+ # an empty arrayref is an empty multi-sub-prefetch - don't consider
+ # those either
for (values %$hash) {
- return $hash if defined $_;
+ if (ref $_ eq 'ARRAY') {
+ return $hash if @$_;
+ }
+ elsif (defined $_) {
+ return $hash;
+ }
}
return undef;
# check nested prefetching of has_many relationships which return nothing
my $artist = $schema->resultset ('Artist')->create ({ name => 'unsuccessful artist without CDs'});
+$artist->discard_changes;
my $rs_artists = $schema->resultset ('Artist')->search ({ 'me.artistid' => $artist->id}, {
- prefetch => { cds => 'tracks' },
-});
-$rs_artists->result_class('DBIx::Class::ResultClass::HashRefInflator');
-my @artists_ok = ({
- artistid => $artist->id,
- name => "unsuccessful artist without CDs",
- cds => [],
+ prefetch => { cds => 'tracks' }, result_class => 'DBIx::Class::ResultClass::HashRefInflator',
});
-is_deeply [$rs_artists->all], \@artists_ok, 'nested has_many prefetch without entries';
+is_deeply(
+ [$rs_artists->all],
+ [{ $artist->get_columns, cds => [] }],
+ 'nested has_many prefetch without entries'
+);