Revision history for SQL::Abstract
+ - Fix erroneous behavior of is_literal_value($) wrt { -ident => ... }
+
revision 1.79 2014-09-25
----------------------------
- New exportable functions: is_literal_value($) and is_plain_value($)
sub is_literal_value ($) {
ref $_[0] eq 'SCALAR' ? [ ${$_[0]} ]
: ( ref $_[0] eq 'REF' and ref ${$_[0]} eq 'ARRAY' ) ? [ @${ $_[0] } ]
- : (
- ref $_[0] eq 'HASH' and keys %{$_[0]} == 1
- and
- defined $_[0]->{-ident} and ! length ref $_[0]->{-ident}
- ) ? [ $_[0]->{-ident} ]
: undef;
}
=item * C<\[ $sql_string, @bind_values ]>
-=item * C<< { -ident => $plain_defined_string } >>
-
=back
On failure returns C<undef>, on sucess returns an B<array> reference
}
is_deeply
- is_literal_value { -ident => 'foo' },
- [ 'foo' ],
- '-ident recognized as literal'
+ is_literal_value \'sql',
+ [ 'sql' ],
+ 'literal correctly recognized and unpacked'
;
is_deeply
is_literal_value \[ 'sql', 'bind1', [ {} => 'bind2' ] ],
[ 'sql', 'bind1', [ {} => 'bind2' ] ],
- 'literal correctly unpacked'
+ 'literal with binds correctly recognized and unpacked'
;