From: John Napiorkowski Date: Mon, 6 May 2019 18:20:47 +0000 (-0500) Subject: another update test X-Git-Tag: v2.000000~3^2~170 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3d47a3014bc4c82f9240548d630a9adfb8c0b6b0;p=dbsrgits%2FSQL-Abstract.git another update test --- diff --git a/xt/clauses.t b/xt/clauses.t index c6d301d..ffdd506 100644 --- a/xt/clauses.t +++ b/xt/clauses.t @@ -423,4 +423,55 @@ is_same_sql_bind( )] ); +($sql, @bind) = $sqlac->update({ + _ => ['survey'], + set => { + license_id => { -ident => 'info.default_license_id' }, + }, + from => [ + -select => { + select => [qw( s.survey_id p.default_license_id p.person_id)], + from => [ + person => -as => 'p', + -join => { + to => 'class', + as => 'c', + on => { 'c.faculty_id' => 'p.person_id' }, + }, + -join => { + to => 'survey', + as => 's', + on => { 's.class_id' => 'c.class_id' }, + }, + ], + where => { 'p.institution_id' => { -value => 15031 } }, + }, + -as => 'info', + ], + where => { + 'info.survey_id' => { -ident => 'survey.survey_id' }, + } +}); + +is_same_sql_bind( + $sql, \@bind, + q{ + update survey + set license_id=info.default_license_id + from ( + select s.survey_id, p.default_license_id, p.person_id + from person AS p + join class AS c on c.faculty_id = p.person_id + join survey AS s on s.class_id = c.class_id + where p.institution_id = ? + ) AS info + where info.survey_id=survey.survey_id + }, + [qw( + 15031 + )] +); + + + done_testing;