12d9129964db7c471a310af48c21327e508cb886
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / SQL / OrderBy.pm
1 package DBIx::Class::SQL::OrderBy;
2
3 use strict;
4 use warnings;
5
6 sub _cond_resolve {
7   my ($self, $cond, $attrs, @rest) = @_;
8   return $self->NEXT::ACTUAL::_cond_resolve($cond, $attrs, @rest)
9     unless wantarray;
10   my ($sql, @bind) = $self->NEXT::ACTUAL::_cond_resolve($cond, $attrs, @rest);
11   if ($attrs->{order_by}) {
12     $sql .= " ORDER BY ".join(', ', (ref $attrs->{order_by} eq 'ARRAY'
13                                      ? @{$attrs->{order_by}}
14                                      : $attrs->{order_by}));
15   }
16   return ($sql, @bind);
17 }
18
19 1;
20
21 =head1 NAME 
22
23 DBIx::Class::SQL::OrderBy - Implements sorting for DBIC's SQL backend
24
25 =head1 SYNOPSIS
26
27 =head1 DESCRIPTION
28
29 This class implements the order_by attribute to L<DBIx::Class>'s search
30 builder.
31
32 =cut
33
34 =head1 AUTHORS
35
36 Matt S. Trout <perl-stuff@trout.me.uk>
37
38 =head1 LICENSE
39
40 You may distribute this code under the same terms as Perl itself.
41
42 =cut