Skip to content

Commit

Permalink
Merge pull request #11 from khiav223577/fix/dangerous_query_method
Browse files Browse the repository at this point in the history
Fix: Non-attribute arguments will be disallowed in Rails 6.0
  • Loading branch information
Rumble Huang authored Feb 10, 2019
2 parents d94948c + 396d9f1 commit 50eba99
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/atomically/query_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def update_all_and_get_ids(*args)
@klass.transaction do
@relation.connection.execute('SET @ids := NULL')
@relation.where("(SELECT @ids := CONCAT_WS(',', #{id_column}, @ids))").update_all(*args) # 撈出有真的被更新的 id,用逗號串在一起
ids = @klass.from(nil).pluck('@ids').first
ids = @klass.from(nil).pluck(Arel.sql('@ids')).first
end
return ids.try{|s| s.split(',').map(&:to_i).uniq.sort } || [] # 將 id 從字串取出來 @id 的格式範例: '1,4,12'
end
Expand Down

0 comments on commit 50eba99

Please # to comment.