From: Matt S Trout Date: Mon, 17 Sep 2018 23:03:45 +0000 (+0000) Subject: add default for ident vs. value X-Git-Tag: v2.000000~3^2~452 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c1c0b98908a0c9d73f97ccb0c8669c24be4fe604;p=dbsrgits%2FSQL-Abstract.git add default for ident vs. value --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 87912b0..d4c8c04 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -528,7 +528,8 @@ sub where { } sub _expand_expr { - my ($self, $expr, $logic) = @_; + my ($self, $expr, $logic, $default_scalar_to) = @_; + local our $Default_Scalar_To = $default_scalar_to if $default_scalar_to; return undef unless defined($expr); if (ref($expr) eq 'HASH') { if (keys %$expr > 1) { @@ -572,6 +573,9 @@ sub _expand_expr { return +{ -literal => $literal }; } if (!ref($expr) or Scalar::Util::blessed($expr)) { + if (my $d = $Default_Scalar_To) { + return +{ $d => $expr }; + } if (my $m = our $Cur_Col_Meta) { return +{ -bind => [ $m, $expr ] }; }