[Bast-commits] r6706 - in DBIx-Class/0.08/trunk: .
lib/DBIx/Class/ResultClass t/inflate
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu Jun 18 10:43:36 GMT 2009
Author: ribasushi
Date: 2009-06-18 10:43:36 +0000 (Thu, 18 Jun 2009)
New Revision: 6706
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultClass/HashRefInflator.pm
DBIx-Class/0.08/trunk/t/inflate/hri.t
Log:
HRI fix
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2009-06-18 10:30:08 UTC (rev 6705)
+++ DBIx-Class/0.08/trunk/Changes 2009-06-18 10:43:36 UTC (rev 6706)
@@ -1,5 +1,10 @@
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)
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultClass/HashRefInflator.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultClass/HashRefInflator.pm 2009-06-18 10:30:08 UTC (rev 6705)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultClass/HashRefInflator.pm 2009-06-18 10:43:36 UTC (rev 6706)
@@ -73,8 +73,15 @@
# 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;
Modified: DBIx-Class/0.08/trunk/t/inflate/hri.t
===================================================================
--- DBIx-Class/0.08/trunk/t/inflate/hri.t 2009-06-18 10:30:08 UTC (rev 6705)
+++ DBIx-Class/0.08/trunk/t/inflate/hri.t 2009-06-18 10:43:36 UTC (rev 6706)
@@ -126,13 +126,12 @@
# 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' },
+ prefetch => { cds => 'tracks' }, result_class => 'DBIx::Class::ResultClass::HashRefInflator',
});
-$rs_artists->result_class('DBIx::Class::ResultClass::HashRefInflator');
-my @artists_ok = ({
- artistid => $artist->id,
- name => "unsuccessful artist without CDs",
- cds => [],
-});
-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'
+);
More information about the Bast-commits
mailing list