$rs = $schema->resultset('CD')->search(undef,
{
'+select' => [ \'COUNT(*) AS year_count' ],
- order_by => 'year_count'
- }
+ order_by => 'year_count'
+ }
);
my @counts = $rs->get_column('cdid')->all;
ok(scalar(@counts), 'got rows from ->all using +select');
cmp_ok ($cds->count, '>', 2, 'Initially populated with more than 2 CDs');
my $table = $cds->result_source->name;
+$table = $$table if ref $table eq 'SCALAR';
my $subsel = $cds->search ({}, {
columns => [qw/cdid title/],
from => \ "(SELECT cdid, title FROM $table LIMIT 2) me",
}
);
-my ($sql, @bind) = @${$rs->as_query};
is_same_sql_bind (
- $sql,
- \@bind,
+ $rs->as_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'
}
);
-($sql, @bind) = @${$rs->as_query};
is_same_sql_bind (
- $sql,
- \@bind,
+ $rs->as_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'