8 my $schema = DBICTest->init_schema();
13 my $rs = $cd = $schema->resultset("CD")->search({});
15 my $rs_title = $rs->get_column('title');
16 my $rs_year = $rs->get_column('year');
17 my $max_year = $rs->get_column(\'MAX (year)');
19 is($rs_title->next, 'Spoonful of bees', "next okay");
20 is_deeply( [ sort $rs_year->func('DISTINCT') ], [ 1997, 1998, 1999, 2001 ], "wantarray context okay");
21 ok ($max_year->next == $rs_year->max, q/get_column (\'FUNC') ok/);
23 my @all = $rs_title->all;
24 cmp_ok(scalar @all, '==', 5, "five titles returned");
26 cmp_ok($rs_year->max, '==', 2001, "max okay for year");
27 is($rs_title->min, 'Caterwaulin\' Blues', "min okay for title");
29 cmp_ok($rs_year->sum, '==', 9996, "three artists returned");
31 my $psrs = $schema->resultset('CD')->search({},
33 '+select' => \'COUNT(*)',
37 ok(defined($psrs->get_column('count')), '+select/+as count');
39 $psrs = $schema->resultset('CD')->search({},
41 '+select' => [ \'COUNT(*)', 'title' ],
42 '+as' => [ 'count', 'addedtitle' ]
45 ok(defined($psrs->get_column('count')), '+select/+as arrayref count');
46 ok(defined($psrs->get_column('addedtitle')), '+select/+as title');
49 my $rs = $schema->resultset("CD")->search({}, { prefetch => 'artist' });
50 my $rsc = $rs->get_column('year');
51 is( $rsc->{_parent_resultset}->{attrs}->{prefetch}, undef, 'prefetch wiped' );