From: Justin Hunter Date: Wed, 1 Dec 2010 00:03:50 +0000 (-0800) Subject: add handling for NULL when using -in X-Git-Tag: v1.72~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=279eb282a990f9527912613255df2c81dff8b05b;p=dbsrgits%2FSQL-Abstract.git add handling for NULL when using -in --- diff --git a/Changes b/Changes index 54b5ee1..40979dc 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ Revision history for SQL::Abstract - Fix parsing of foo.* in SQLA::Tree - Fix bindtype fail when using -between with arrayrefref literals + - Add handling for NULL for -in revision 1.71 2010-11-09 ---------------------------- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 5944c62..163bfa0 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -961,7 +961,10 @@ sub _where_field_IN { if (@rest or $func !~ /^ \- (.+)/x); local $self->{_nested_func_lhs} = $k; $self->_where_unary_op ($1 => $arg); - } + }, + UNDEF => sub { + return $self->_sqlcase('null'); + }, }); push @all_sql, $sql; push @all_bind, @bind; diff --git a/t/05in_between.t b/t/05in_between.t index 22218c0..2ae90cf 100644 --- a/t/05in_between.t +++ b/t/05in_between.t @@ -172,6 +172,18 @@ my @in_between_tests = ( bind => [qw/A c/], test => '-in with an array of function array refs with args', }, + { + where => { x => { -in => [ 1, undef ] } }, + stmt => " WHERE ( x IN ( ?, NULL ) )", + bind => [ 1 ], + test => '-in with undef as an element', + }, + { + where => { x => { -in => [ 1, undef, 2, 3, undef ] } }, + stmt => " WHERE ( x IN ( ?, NULL, ?, ?, NULL ) )", + bind => [ 1, 2, 3 ], + test => '-in with undef as an element', + }, ); plan tests => @in_between_tests*4;