[Bast-commits] r5020 - in DBIx-Class/0.08/trunk: lib/DBIx/Class t
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed Oct 29 11:18:44 GMT 2008
Author: ribasushi
Date: 2008-10-29 11:18:44 +0000 (Wed, 29 Oct 2008)
New Revision: 5020
Added:
DBIx-Class/0.08/trunk/t/76select.t
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
Log:
Minor chaining patch + test by Norbert Buchmuller (chaining needs a massive cleanup, delayed until next release)
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2008-10-28 16:36:57 UTC (rev 5019)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2008-10-29 11:18:44 UTC (rev 5020)
@@ -200,7 +200,7 @@
my $new_attrs = { %{$our_attrs}, %{$attrs} };
# merge new attrs into inherited
- foreach my $key (qw/join prefetch/) {
+ foreach my $key (qw/join prefetch +select +as/) {
next unless exists $attrs->{$key};
$new_attrs->{$key} = $self->_merge_attr($our_attrs->{$key}, $attrs->{$key});
}
Added: DBIx-Class/0.08/trunk/t/76select.t
===================================================================
--- DBIx-Class/0.08/trunk/t/76select.t (rev 0)
+++ DBIx-Class/0.08/trunk/t/76select.t 2008-10-29 11:18:44 UTC (rev 5020)
@@ -0,0 +1,44 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 7;
+
+my $rs = $schema->resultset('CD')->search({},
+ {
+ '+select' => \ 'COUNT(*)',
+ '+as' => 'count'
+ }
+);
+lives_ok(sub { $rs->first->get_column('count') }, 'additional count rscolumn present');
+dies_ok(sub { $rs->first->get_column('nonexistent_column') }, 'nonexistant column requests still throw exceptions');
+
+$rs = $schema->resultset('CD')->search({},
+ {
+ '+select' => [ \ 'COUNT(*)', 'title' ],
+ '+as' => [ 'count', 'addedtitle' ]
+ }
+);
+lives_ok(sub { $rs->first->get_column('count') }, 'multiple +select/+as columns, 1st rscolumn present');
+lives_ok(sub { $rs->first->get_column('addedtitle') }, 'multiple +select/+as columns, 2nd rscolumn present');
+
+$rs = $schema->resultset('CD')->search({},
+ {
+ '+select' => [ \ 'COUNT(*)', 'title' ],
+ '+as' => [ 'count', 'addedtitle' ]
+ }
+)->search({},
+ {
+ '+select' => 'title',
+ '+as' => 'addedtitle2'
+ }
+);
+lives_ok(sub { $rs->first->get_column('count') }, '+select/+as chained search 1st rscolumn present');
+lives_ok(sub { $rs->first->get_column('addedtitle') }, '+select/+as chained search 1st rscolumn present');
+lives_ok(sub { $rs->first->get_column('addedtitle2') }, '+select/+as chained search 3rd rscolumn present');
Property changes on: DBIx-Class/0.08/trunk/t/76select.t
___________________________________________________________________
Name: svn:mergeinfo
+
More information about the Bast-commits
mailing list