From: Matt S Trout Date: Sun, 31 Jul 2011 06:15:11 +0000 (+0000) Subject: fix expression generation for UPDATE X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=427ef96910d7db09bed88b5c6e8cb548c6dd3807;p=dbsrgits%2FSQL-Abstract.git fix expression generation for UPDATE --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index d8c274c..f4434b6 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -408,7 +408,8 @@ sub update { if (@rest or not $op =~ /^\-(.+)/); local $self->{_nested_func_lhs} = $k; - my ($sql, @bind) = $self->_where_unary_op ($1, $arg); + local our $Cur_Col_Meta = $k; + my ($sql, @bind) = $self->_render_dq($self->_where_to_dq({ $op => $arg })); push @set, "$label = $sql"; push @all_bind, @bind; diff --git a/t/01generate.t b/t/01generate.t index 90e94f8..eb268a2 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -451,8 +451,8 @@ my @tests = ( func => 'update', new => {bindtype => 'columns'}, args => ['test', {a => 1, b => \["to_date(?, 'MM/DD/YY')", [{dummy => 1} => '02/02/02']], c => { -lower => 'foo' }}, {a => {'between', [1,2]}}], - stmt => "UPDATE test SET a = ?, b = to_date(?, 'MM/DD/YY'), c = LOWER ? WHERE ( a BETWEEN ? AND ? )", - stmt_q => "UPDATE `test` SET `a` = ?, `b` = to_date(?, 'MM/DD/YY'), `c` = LOWER ? WHERE ( `a` BETWEEN ? AND ? )", + stmt => "UPDATE test SET a = ?, b = to_date(?, 'MM/DD/YY'), c = LOWER(?) WHERE ( a BETWEEN ? AND ? )", + stmt_q => "UPDATE `test` SET `a` = ?, `b` = to_date(?, 'MM/DD/YY'), `c` = LOWER(?) WHERE ( `a` BETWEEN ? AND ? )", bind => [[a => '1'], [{dummy => 1} => '02/02/02'], [c => 'foo'], [a => '1'], [a => '2']], }, {