X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FAbstract.pm;h=24a1c8763ad4db85e24bc4a5139ea17d87d24c3e;hb=eb49170d9524af0a98dbe02cba213d82be6f0cc3;hp=e0f1cad7cb548f8c856ff470d13f9d1a3ef07eb0;hpb=daeddb7026e62a6cadd4ba6236be9aa223b52726;p=scpubgit%2FQ-Branch.git diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index e0f1cad..24a1c87 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -528,9 +528,10 @@ sub _where_hashpair_ARRAYREF { } sub _where_hashpair_HASHREF { - my ($self, $k, $v) = @_; + my ($self, $k, $v, $logic) = @_; + $logic ||= 'and'; - my (@all_sql, @all_bind); + my ($all_sql, @all_bind); for my $op (sort keys %$v) { my $val = $v->{$op}; @@ -571,6 +572,10 @@ sub _where_hashpair_HASHREF { @bind = @sub_bind; }, + HASHREF => sub { + ($sql, @bind) = $self->_where_hashpair_HASHREF($k, $val, $op); + }, + UNDEF => sub { # CASE: col => {op => undef} : sql "IS (NOT)? NULL" my $is = ($op =~ $self->{equality_op}) ? 'is' : ($op =~ $self->{inequality_op}) ? 'is not' : @@ -587,11 +592,10 @@ sub _where_hashpair_HASHREF { }); } - push @all_sql, $sql; + ($all_sql) = (defined $all_sql and $all_sql) ? $self->_join_sql_clauses($logic, [$all_sql, $sql], []) : $sql; push @all_bind, @bind; } - - return $self->_join_sql_clauses('and', \@all_sql, \@all_bind); + return ($all_sql, @all_bind); }