From: Peter Rabbitson Date: Thu, 4 Sep 2014 10:29:49 +0000 (+0200) Subject: { -ident => undef } makes zero sense X-Git-Tag: v1.79~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FSQL-Abstract.git;a=commitdiff_plain;h=8aa76984c08d55d3a4e37ce4fde6c9f7169e2e6e { -ident => undef } makes zero sense --- diff --git a/Changes b/Changes index c154cdc..99eadea 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ Revision history for SQL::Abstract - New attribute 'escape_char' allowing for proper escape of quote_chars present in an identifier - Treat { -value => undef } as plain undef in all cases + - Explicitly throw on { -ident => undef } revision 1.78 2014-05-28 ---------------------------- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 37d83cc..54408df 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -738,8 +738,8 @@ sub _where_op_BOOL { sub _where_op_IDENT { my $self = shift; my ($op, $rhs) = splice @_, -2; - if (ref $rhs) { - puke "-$op takes a single scalar argument (a quotable identifier)"; + if (! defined $rhs or length ref $rhs) { + puke "-$op requires a single plain scalar argument (a quotable identifier)"; } # in case we are called as a top level special op (no '=') diff --git a/t/21op_ident.t b/t/21op_ident.t index 5ba3f27..29ff46f 100644 --- a/t/21op_ident.t +++ b/t/21op_ident.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; +use Test::Exception; use SQL::Abstract; use SQL::Abstract::Test import => [qw/is_same_sql_bind/]; @@ -12,6 +13,10 @@ for my $q ('', '"') { name_sep => $q ? '.' : '', ); + throws_ok { + $sql_maker->where({ foo => { -ident => undef } }) + } qr/-ident requires a single plain scalar argument/; + my ($sql, @bind) = $sql_maker->select ('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } ); is_same_sql_bind ( $sql,