From: Matt S Trout Date: Wed, 17 Oct 2018 22:44:29 +0000 (+0000) Subject: restore _order_by exception on nonsense asc+desc input X-Git-Tag: v1.90_01~414 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=70c57fc3babeb2f14b0bedc588ae90fb54ceeabe;p=dbsrgits%2FSQL-Abstract.git restore _order_by exception on nonsense asc+desc input --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 2c0034b..b101747 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -1056,6 +1056,14 @@ sub _order_by { return (@exp > 1 ? { -op => [ ',', @exp ] } : $exp[0]); }; + if ( + ref($arg) eq 'HASH' + and keys %$arg > 1 + and grep /^-(asc|desc)$/, keys %$arg + ) { + puke "ordering direction hash passed to order by must have exactly one key (-asc or -desc)"; + } + local @{$self->{expand_unary}}{qw(-asc -desc)} = ( sub { shift->$expander(asc => @_) }, sub { shift->$expander(desc => @_) }, diff --git a/t/06order_by.t b/t/06order_by.t index 1095862..7d1213e 100644 --- a/t/06order_by.t +++ b/t/06order_by.t @@ -127,12 +127,6 @@ for my $case (@cases) { ); } -# meh - -done_testing; - -exit; - throws_ok ( sub { $sql->_order_by({-desc => 'colA', -asc => 'colB' }) }, qr/hash passed .+ must have exactly one key/,