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