From: Arthur Axel 'fREW' Schmidt Date: Wed, 2 Feb 2011 21:58:34 +0000 (-0600) Subject: add an "escape hatch" to use _recurse_where from select X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e0971d1e0dc33814ade446285f052dc35b3587ab;p=dbsrgits%2FDBIx-Class.git add an "escape hatch" to use _recurse_where from select --- diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index 9050fcc..fbc3911 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -297,13 +297,20 @@ sub insert { } sub _recurse_fields { - my ($self, $fields) = @_; + my ($self, $fields, $depth) = @_; + $depth ||= 0; my $ref = ref $fields; return $self->_quote($fields) unless $ref; return $$fields if $ref eq 'SCALAR'; if ($ref eq 'ARRAY') { - return join(', ', map { $self->_recurse_fields($_) } @$fields); + return join(', ', map { $self->_recurse_fields($_, $depth + 1) } @$fields) + if $depth != 1; + + my ($sql, @bind) = $self->_recurse_where({@$fields}); + + push @{$self->{select_bind}}, @bind; + return $sql; } elsif ($ref eq 'HASH') { my %hash = %$fields; # shallow copy @@ -327,7 +334,7 @@ sub _recurse_fields { my $select = sprintf ('%s( %s )%s', $self->_sqlcase($func), - $self->_recurse_fields($args), + $self->_recurse_fields($args, $depth + 1), $as ? sprintf (' %s %s', $self->_sqlcase('as'), $self->_quote ($as) ) : ''