[Bast-commits] r6015 - in DBIx-Class/0.08/trunk: lib/DBIx/Class t
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed Apr 29 08:22:16 GMT 2009
Author: ribasushi
Date: 2009-04-29 09:22:16 +0100 (Wed, 29 Apr 2009)
New Revision: 6015
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
DBIx-Class/0.08/trunk/t/76select.t
Log:
test and patch for failing mini-prefetch via columns (arcanez++)
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2009-04-29 07:27:15 UTC (rev 6014)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2009-04-29 08:22:16 UTC (rev 6015)
@@ -1029,7 +1029,6 @@
$fetched = $pre_source->result_class->inflate_result(
$pre_source, @{$pre_val});
}
- $new->related_resultset($pre)->set_cache([ $fetched ]);
my $accessor = $source->relationship_info($pre)->{attrs}{accessor};
$class->throw_exception("No accessor for prefetched $pre")
unless defined $accessor;
@@ -1040,6 +1039,7 @@
} else {
$class->throw_exception("Prefetch not supported with accessor '$accessor'");
}
+ $new->related_resultset($pre)->set_cache([ $fetched ]);
}
}
return $new;
Modified: DBIx-Class/0.08/trunk/t/76select.t
===================================================================
--- DBIx-Class/0.08/trunk/t/76select.t 2009-04-29 07:27:15 UTC (rev 6014)
+++ DBIx-Class/0.08/trunk/t/76select.t 2009-04-29 08:22:16 UTC (rev 6015)
@@ -5,10 +5,11 @@
use Test::Exception;
use lib qw(t/lib);
use DBICTest;
+use DBIC::SqlMakerTest;
my $schema = DBICTest->init_schema();
-plan tests => 13;
+plan tests => 19;
my $rs = $schema->resultset('CD')->search({},
{
@@ -74,9 +75,55 @@
is($schema->resultset('CD')->current_source_alias, "me", '$rs->current_source_alias returns "me"');
-my @cds = $schema->resultset('CD')->search({},
+
+
+$rs = $schema->resultset('CD')->search({},
{
'join' => 'artist',
- 'columns' => ['cdid','title','artist.name'],
+ 'columns' => ['cdid', 'title', 'artist.name'],
}
);
+
+my @query = @${$rs->as_query};
+
+is_same_sql_bind (
+ @query,
+ [],
+ '(SELECT me.cdid, me.title, artist.name FROM cd me JOIN artist artist ON artist.artistid = me.artist)',
+ [],
+ 'Use of columns attribute results in proper sql'
+);
+
+lives_ok(sub {
+ $rs->first->get_column('cdid')
+}, 'columns 1st rscolumn present');
+
+lives_ok(sub {
+ $rs->first->get_column('title')
+}, 'columns 2nd rscolumn present');
+
+
+$rs = $schema->resultset('CD')->search({},
+ {
+ 'join' => 'artist',
+ '+columns' => ['cdid', 'title', 'artist.name'],
+ }
+);
+
+ at query = @${$rs->as_query};
+
+is_same_sql_bind (
+ @query,
+ [],
+ '(SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track, me.cdid, me.title, artist.name FROM cd me JOIN artist artist ON artist.artistid = me.artist)',
+ [],
+ 'Use of columns attribute results in proper sql'
+);
+
+lives_ok(sub {
+ $rs->first->get_column('cdid')
+}, 'columns 1st rscolumn present');
+
+lives_ok(sub {
+ $rs->first->get_column('title')
+}, 'columns 2nd rscolumn present');
More information about the Bast-commits
mailing list