From: Matt S Trout Date: Mon, 7 May 2012 15:00:59 +0000 (+0000) Subject: document order by madness X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8b9b83ae;p=dbsrgits%2FSQL-Abstract.git document order by madness --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 4b9eaa1..05ddfbd 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -5,6 +5,7 @@ use List::Util (); use Scalar::Util (); use Module::Runtime qw(use_module); use Moo; +use namespace::clean; our $VERSION = '1.72'; diff --git a/lib/SQL/Abstract/Converter.pm b/lib/SQL/Abstract/Converter.pm index eab3e4e..bc3efed 100644 --- a/lib/SQL/Abstract/Converter.pm +++ b/lib/SQL/Abstract/Converter.pm @@ -9,6 +9,7 @@ use Data::Query::Constants qw( ); use Data::Query::ExprHelpers qw(perl_scalar_value); use Moo; +use namespace::clean; has renderer_will_quote => ( is => 'ro' @@ -575,6 +576,17 @@ sub _order_by_to_dq { } elsif (ref($arg) eq 'REF' and ref($$arg) eq 'ARRAY') { $dq->{by} = $self->_literal_to_dq($$arg); } elsif (ref($arg) eq 'SCALAR') { + + # < mst> right, but if it doesn't match that, it goes "ok, right, not sure, + # totally leaving this untouched as a literal" + # < mst> so I -think- it's relatively robust + # < ribasushi> right, it's relatively safe then + # < ribasushi> is this regex centralized? + # < mst> it only exists in _order_by_to_dq in SQL::Abstract::Converter + # < mst> it only exists because you were kind enough to support new + # dbihacks crack combined with old literal order_by crack + # < ribasushi> heh :) + if (my ($ident, $dir) = $$arg =~ /^(\w+)(?:\s+(desc|asc))?$/i) { $dq->{by} = $self->_ident_to_dq($ident); $dq->{reverse} = 1 if $dir and lc($dir) eq 'desc';