From: Matt S Trout Date: Mon, 16 Apr 2012 07:11:45 +0000 (+0000) Subject: refactor a bit more, honour literals in converter X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=87af42042b608bfeafd420ae66cfa31c1e865f74;p=dbsrgits%2FSQL-Abstract.git refactor a bit more, honour literals in converter --- diff --git a/lib/SQL/Abstract/Converter.pm b/lib/SQL/Abstract/Converter.pm index 2ce72cf..b7380dd 100644 --- a/lib/SQL/Abstract/Converter.pm +++ b/lib/SQL/Abstract/Converter.pm @@ -230,32 +230,37 @@ sub _select_to_dq { } }; - return $self->_select_list_to_dq($fields, $ordered_dq); + return $self->_select_select_to_dq($fields, $ordered_dq); } -sub _select_list_to_dq { +sub _select_select_to_dq { my ($self, $fields, $from_dq) = @_; $fields ||= '*'; return +{ type => DQ_SELECT, - select => [ $self->_select_field_list_to_dq($fields) ], + select => $self->_select_field_list_to_dq($fields), from => $from_dq, }; } sub _select_field_list_to_dq { my ($self, $fields) = @_; - map $self->_select_field_to_dq($_), - ref($fields) eq 'ARRAY' ? @$fields : $fields; + [ map $self->_select_field_to_dq($_), + ref($fields) eq 'ARRAY' ? @$fields : $fields ]; } sub _select_field_to_dq { my ($self, $field) = @_; - ref($field) - ? $self->_literal_to_dq($$field) - : $self->_ident_to_dq($field) + if (my $ref = ref($field)) { + if ($ref eq 'REF' and ref($$field) eq 'HASH') { + return $$field; + } else { + return $self->_literal_to_dq($$field); + } + } + return $self->_ident_to_dq($field) } sub _delete_to_dq {