Retire DBIC/SqlMakerTest.pm now that SQLA::Test provides the same function
[dbsrgits/DBIx-Class.git] / t / sqlmaker / order_by_func.t
1 use strict;
2 use warnings;
3 use Test::More;
4
5 use lib qw(t/lib);
6 use DBICTest ':DiffSQL';
7
8 my $schema = DBICTest->init_schema();
9
10 my $rs = $schema->resultset('CD')->search({}, {
11     'join' => 'tracks',
12     order_by => {
13         -desc => {
14             count => 'tracks.track_id',
15         },
16     },
17     distinct => 1,
18     rows => 2,
19     page => 1,
20 });
21 my $match = q{
22     SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me
23     GROUP BY me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
24     ORDER BY COUNT(tracks.trackid) DESC
25 };
26
27 TODO: {
28     todo_skip 'order_by using function', 2;
29     is_same_sql($rs->as_query, $match, 'order by with func query');
30
31     ok($rs->count == 2, 'amount of rows return in order by func query');
32 }
33
34 done_testing;