From: Guillermo Roditi Date: Thu, 15 May 2008 20:28:33 +0000 (+0000) Subject: one more test and some simple docs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1cfa1db38710ee8109475c4b9cd2d42bc2e3e178;p=scpubgit%2FQ-Branch.git one more test and some simple docs --- diff --git a/Changes b/Changes index 9eb8103..431fc26 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,8 @@ Revision history for SQL::Abstract - Added { -desc => 'column' } order by support (Ash) - - Tiny fix for { -desc => 'columns'} order by support + tests (groditi) + - Tiny "$_"-related fix for { -desc => 'columns'} order by support + - tests + docs (groditi) ---------------------------- revision 1.20 diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 102958f..6816a52 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -1271,7 +1271,21 @@ script. Some functions take an order by clause. This can either be a scalar (just a column name,) a hash of C<< { -desc => 'col' } >> or C<< { -asc => 'col' } >>, -or an array of either of the two previous forms. +or an array of either of the two previous forms. Examples: + + Given | Will Generate + ---------------------------------------------------------- + \'colA DESC' | ORDER BY colA DESC + 'colA' | ORDER BY colA + [qw/colA colB/] | ORDER BY colA, colB + {-asc => 'colA'} | ORDER BY colA ASC + {-desc => 'colB'} | ORDER BY colB DESC + [ | + {-asc => 'colA'}, | ORDER BY colA ASC, colB DESC + {-desc => 'colB'} | + ] | + [colA => {-asc => 'colB'}] | ORDER BY colA, colB ASC + ========================================================== =head1 PERFORMANCE diff --git a/t/06order_by.t b/t/06order_by.t index 2fdd43a..20ca3f4 100644 --- a/t/06order_by.t +++ b/t/06order_by.t @@ -38,6 +38,11 @@ my @cases = expects => ' ORDER BY colA ASC, colB DESC', expects_quoted => ' ORDER BY `colA` ASC, `colB` DESC', }, + { + given => ['colA', {-desc => 'colB'}], + expects => ' ORDER BY colA, colB DESC', + expects_quoted => ' ORDER BY `colA`, `colB` DESC', + }, ); my $sql = SQL::Abstract->new;