Test for search_rs destructive effects on attributes - see fix in [2674]
[dbsrgits/DBIx-Class.git] / t / 88result_set_column.t
index e05dbb4..936a0a7 100644 (file)
@@ -5,10 +5,11 @@ use Test::More;
 use lib qw(t/lib);
 use DBICTest;
 
-my $schema = DBICTest::init_schema();
+my $schema = DBICTest->init_schema();
 
-plan tests => 5; 
+plan tests => 8; 
 
+my $cd;
 my $rs = $cd = $schema->resultset("CD")->search({});
 
 my $rs_title = $rs->get_column('title');
@@ -24,3 +25,20 @@ is($rs_title->min, 'Caterwaulin\' Blues', "min okay for title");
 
 cmp_ok($rs_year->sum, '==', 9996, "three artists returned");
 
+my $psrs = $schema->resultset('CD')->search({},
+    {
+        '+select'   => \'COUNT(*)',
+        '+as'       => 'count'
+    }
+);
+ok(defined($psrs->get_column('count')), '+select/+as count');
+
+$psrs = $schema->resultset('CD')->search({},
+    {
+        '+select'   => [ \'COUNT(*)', 'title' ],
+        '+as'       => [ 'count', 'addedtitle' ]
+    }
+);
+ok(defined($psrs->get_column('count')), '+select/+as arrayref count');
+ok(defined($psrs->get_column('addedtitle')), '+select/+as title');
+