9 use SQL::Abstract::Test import => ['is_same_sql_bind'];
13 given => \'colA DESC',
14 expects => ' ORDER BY colA DESC',
15 expects_quoted => ' ORDER BY colA DESC',
19 expects => ' ORDER BY colA',
20 expects_quoted => ' ORDER BY `colA`',
22 { # it may look odd, but this is the desired behaviour (mst)
24 expects => ' ORDER BY colA DESC',
25 expects_quoted => ' ORDER BY `colA DESC`',
28 given => [qw/colA colB/],
29 expects => ' ORDER BY colA, colB',
30 expects_quoted => ' ORDER BY `colA`, `colB`',
32 { # it may look odd, but this is the desired behaviour (mst)
33 given => ['colA ASC', 'colB DESC'],
34 expects => ' ORDER BY colA ASC, colB DESC',
35 expects_quoted => ' ORDER BY `colA ASC`, `colB DESC`',
38 given => {-asc => 'colA'},
39 expects => ' ORDER BY colA ASC',
40 expects_quoted => ' ORDER BY `colA` ASC',
43 given => {-desc => 'colB'},
44 expects => ' ORDER BY colB DESC',
45 expects_quoted => ' ORDER BY `colB` DESC',
48 given => [{-asc => 'colA'}, {-desc => 'colB'}],
49 expects => ' ORDER BY colA ASC, colB DESC',
50 expects_quoted => ' ORDER BY `colA` ASC, `colB` DESC',
53 given => ['colA', {-desc => 'colB'}],
54 expects => ' ORDER BY colA, colB DESC',
55 expects_quoted => ' ORDER BY `colA`, `colB` DESC',
65 plan tests => (scalar(@cases) * 2);
67 my $sql = SQL::Abstract->new;
68 my $sqlq = SQL::Abstract->new({quote_char => '`'});
70 for my $case( @cases){
71 is($sql->_order_by($case->{given}), $case->{expects});
72 is($sqlq->_order_by($case->{given}), $case->{expects_quoted});