bumped version but not $REVISION. small fix to order_by plus more tests. docs pending
[scpubgit/Q-Branch.git] / t / 06order_by.t
CommitLineData
f5aab26e 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use Test::More;
6
7use SQL::Abstract;
8
9my @cases =
10 (
11 {
12 given => \'colA DESC',
13 expects => ' ORDER BY colA DESC',
14 expects_quoted => ' ORDER BY colA DESC',
15 },
16 {
17 given => 'colA',
18 expects => ' ORDER BY colA',
19 expects_quoted => ' ORDER BY `colA`',
20 },
21 {
22 given => [qw/colA colB/],
23 expects => ' ORDER BY colA, colB',
24 expects_quoted => ' ORDER BY `colA`, `colB`',
25 },
26 {
27 given => {-asc => 'colA'},
28 expects => ' ORDER BY colA ASC',
29 expects_quoted => ' ORDER BY `colA` ASC',
30 },
31 {
32 given => {-desc => 'colB'},
33 expects => ' ORDER BY colB DESC',
34 expects_quoted => ' ORDER BY `colB` DESC',
35 },
36 {
37 given => [{-asc => 'colA'}, {-desc => 'colB'}],
38 expects => ' ORDER BY colA ASC, colB DESC',
39 expects_quoted => ' ORDER BY `colA` ASC, `colB` DESC',
40 },
41 );
42
43my $sql = SQL::Abstract->new;
44my $sqlq = SQL::Abstract->new({quote_char => '`'});
45
46plan tests => (scalar(@cases) * 2);
47
48for my $case( @cases){
49 is($sql->_order_by($case->{given}), $case->{expects});
50 is($sqlq->_order_by($case->{given}), $case->{expects_quoted});
51}