From: Matt S Trout Date: Sun, 17 Jul 2011 02:09:00 +0000 (+0000) Subject: generate SELECT list using DQ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b9ace5b3d219f832aefe1865db62ec5bbb6269d8;p=dbsrgits%2FSQL-Abstract.git generate SELECT list using DQ --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index dda95a9..6a04b42 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -11,7 +11,7 @@ use Carp (); use List::Util (); use Scalar::Util (); use Data::Query::Constants qw( - DQ_IDENTIFIER DQ_OPERATOR DQ_VALUE DQ_LITERAL DQ_JOIN + DQ_IDENTIFIER DQ_OPERATOR DQ_VALUE DQ_LITERAL DQ_JOIN DQ_SELECT ); #====================================================================== @@ -384,10 +384,16 @@ sub select { my($where_sql, @bind) = $self->where($where, $order); - my $f = (ref $fields eq 'ARRAY') ? join ', ', map { $self->_quote($_) } @$fields - : $fields; - my $sql = join(' ', $self->_sqlcase('select'), $f, - $self->_sqlcase('from'), $table) + my $select = $self->_render_dq({ + type => DQ_SELECT, + select => [ + map +{ + type => DQ_IDENTIFIER, + elements => [ split /\Q$self->{name_sep}/, $_ ], + }, ref($fields) eq 'ARRAY' ? @$fields : $fields + ], + }); + my $sql = join(' ', $select, $self->_sqlcase('from'), $table) . $where_sql; return wantarray ? ($sql, @bind) : $sql;