From: John Napiorkowski Date: Mon, 6 May 2019 18:20:47 +0000 (-0500) Subject: another update test X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=48b71e3b7c1fb4e370236037cf914c8034d0ab80;p=scpubgit%2FQ-Branch.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;