[Bast-commits] r8000 - in DBIx-Class/0.08/branches/prefetch:
lib/DBIx/Class t/prefetch
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon Nov 30 23:47:08 GMT 2009
Author: ribasushi
Date: 2009-11-30 23:47:08 +0000 (Mon, 30 Nov 2009)
New Revision: 8000
Modified:
DBIx-Class/0.08/branches/prefetch/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/prefetch/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/branches/prefetch/t/prefetch/_util.t
Log:
Restore backwards compatibility - introduce intent to collapse flag
Modified: DBIx-Class/0.08/branches/prefetch/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/prefetch/lib/DBIx/Class/ResultSet.pm 2009-11-30 23:44:28 UTC (rev 7999)
+++ DBIx-Class/0.08/branches/prefetch/lib/DBIx/Class/ResultSet.pm 2009-11-30 23:47:08 UTC (rev 8000)
@@ -1003,7 +1003,7 @@
do {
my $i = 0;
my $row = { map { $_ => $row[ $i++ ] } @$as_proto };
- $row = $self->result_source->_parse_row($row);
+ $row = $self->result_source->_parse_row($row, $collapse);
unless ( scalar @$rows ) {
push( @$rows, $row );
}
Modified: DBIx-Class/0.08/branches/prefetch/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/prefetch/lib/DBIx/Class/ResultSource.pm 2009-11-30 23:44:28 UTC (rev 7999)
+++ DBIx-Class/0.08/branches/prefetch/lib/DBIx/Class/ResultSource.pm 2009-11-30 23:47:08 UTC (rev 8000)
@@ -1504,9 +1504,14 @@
# The structure is constructed taking into account relationship metadata
# (single vs multi).
# The resulting arrayref resembles the arguments to ::Row::inflate_result
-# For an example look at t/prefetch/_util.t:
+# For an example look at t/prefetch/_util.t
+#
+# The will collapse flag is for backwards compatibility only - if it is
+# set, all relationship row-parts are returned as hashes, even if some
+# of these relationships are has_many's
+#
sub _parse_row {
- my ( $self, $row ) = @_;
+ my ( $self, $row, $will_collapse ) = @_;
my ($me, $pref);
@@ -1523,10 +1528,10 @@
my $rel_info = $self->relationship_info($rel);
$pref->{$rel} =
- $self->related_source($rel)->_parse_row( $pref->{$rel} );
+ $self->related_source($rel)->_parse_row( $pref->{$rel}, $will_collapse );
$pref->{$rel} = [ $pref->{$rel} ]
- if ( $rel_info->{attrs}{accessor} eq 'multi' );
+ if ( $will_collapse && $rel_info->{attrs}{accessor} eq 'multi' );
}
return [ $me||{}, $pref||() ];
Modified: DBIx-Class/0.08/branches/prefetch/t/prefetch/_util.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch/t/prefetch/_util.t 2009-11-30 23:44:28 UTC (rev 7999)
+++ DBIx-Class/0.08/branches/prefetch/t/prefetch/_util.t 2009-11-30 23:47:08 UTC (rev 8000)
@@ -21,7 +21,8 @@
'cd.artist.artistid' => '1',
'cd.artist.name' => 'Caterwauler McCrae',
- },
+ },
+ 'will collapse'
);
is_deeply (
@@ -57,7 +58,7 @@
]
}
],
- '_parse_row works as expected',
+ '_parse_row works as expected with expected collapse',
);
$irow = $schema->source ('Artist')->_parse_row (
@@ -76,30 +77,26 @@
},
{
'cds' => [
- [
- {},
- {
- 'tracks' => [
- [
+ {},
+ {
+ 'tracks' => [
+ {
+ 'cd' => '3',
+ 'title' => 'Fowlin'
+ },
+ {
+ 'cd_single' => [
{
- 'cd' => '3',
- 'title' => 'Fowlin'
+ title => 'Awesome single',
},
- {
- 'cd_single' => [
- {
- title => 'Awesome single',
- },
- ],
- },
- ]
- ]
- }
- ]
+ ],
+ },
+ ]
+ }
]
}
],
- '_parse_row works over missing joins',
+ '_parse_row works over missing joins without collapse',
);
done_testing;
More information about the Bast-commits
mailing list