Skip to content

Commit

Permalink
rails 5: fix update_all with joins
Browse files Browse the repository at this point in the history
refs CNVS-34862

Change-Id: If94c3ad82035a4d92f1f8811ee91b46701bc7abd
Reviewed-on: https://gerrit.instructure.com/102248
Tested-by: Jenkins
Reviewed-by: Simon Williams <[email protected]>
Product-Review: Cody Cutrer <[email protected]>
QA-Review: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer committed Feb 15, 2017
1 parent 5f3a11c commit 37aa79e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/initializers/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -920,10 +920,10 @@ def deconstruct_joins(joins_sql=nil)
def update_all(updates, *args)
return super if joins_values.empty?

stmt = Arel::UpdateManager.new(arel.engine)
stmt = CANVAS_RAILS4_2 ? Arel::UpdateManager.new(arel.engine) : Arel::UpdateManager.new

stmt.set Arel.sql(@klass.send(:sanitize_sql_for_assignment, updates))
from = from_value.try(:first)
from = (CANVAS_RAILS4_2 ? from_value : from_clause).try(:first)
stmt.table(from ? Arel::Nodes::SqlLiteral.new(from) : table)
stmt.key = table[primary_key]

Expand Down

0 comments on commit 37aa79e

Please sign in to comment.