From: Rob Kinyon Date: Mon, 9 Mar 2009 00:35:23 +0000 (+0000) Subject: Fixed interjecting arrayrefref into a where clause X-Git-Tag: v1.70~219 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=474e33354b67e58e0bb4fa532adb3c01b148f36e;p=dbsrgits%2FSQL-Abstract.git Fixed interjecting arrayrefref into a where clause --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 8e2e6bb..90434b8 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -386,6 +386,8 @@ sub _where_ARRAYREF { # skip empty elements, otherwise get invalid trailing AND stuff ARRAYREF => sub {$self->_recurse_where($el) if @$el}, + ARRAYREFREF => sub { @{${$el}} if @{${$el}}}, + HASHREF => sub {$self->_recurse_where($el, 'and') if %$el}, # LDNOTE : previous SQLA code for hashrefs was creating a dirty # side-effect: the first hashref within an array would change @@ -410,7 +412,16 @@ sub _where_ARRAYREF { return $self->_join_sql_clauses($logic, \@sql_clauses, \@all_bind); } +#====================================================================== +# WHERE: top-level ARRAYREFREF +#====================================================================== +sub _where_ARRAYREFREF { + my ($self, $where) = @_; + my ($sql, @bind) = @{${$where}}; + + return ($sql, @bind); +} #====================================================================== # WHERE: top-level HASHREF diff --git a/t/02where.t b/t/02where.t index 94ce7d5..b169de1 100644 --- a/t/02where.t +++ b/t/02where.t @@ -14,6 +14,7 @@ use SQL::Abstract; my $not_stringifiable = bless {}, 'SQLA::NotStringifiable'; my@x=( +);my @handle_tests = ( { where => { requestor => 'inna', @@ -196,19 +197,18 @@ my@x=( bind => [ $not_stringifiable ], }, -);my @handle_tests = ( { - where => \[ 'foo ?','bar' ], + where => \[ 'foo = ?','bar' ], stmt => " WHERE (foo = ?)", bind => [ "bar" ], }, -);my@x2=( { - where => [ \[ 'foo ?','bar' ] ], + where => [ \[ 'foo = ?','bar' ] ], stmt => " WHERE (foo = ?)", bind => [ "bar" ], }, +);my@x2=( ); diff --git a/t/03values.t b/t/03values.t index a9e3946..db28ab0 100644 --- a/t/03values.t +++ b/t/03values.t @@ -109,5 +109,5 @@ for my $record (@data) { [$sql->values ($data)], [@bind], 'values() output matches that of initial bind' - ) || diag "Corresponding SQL statement: $stmt"; + );# || diag "Corresponding SQL statement: $stmt"; }