From 396d9f162aa6a8f4765b0cfeef766c51356e05b5 Mon Sep 17 00:00:00 2001 From: Rumble Huang Date: Sun, 10 Feb 2019 16:47:19 +0800 Subject: [PATCH] Fix: Non-attribute arguments will be disallowed in Rails 6.0 DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "@ids" --- lib/atomically/query_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/atomically/query_service.rb b/lib/atomically/query_service.rb index 9c162ee..3f987bc 100644 --- a/lib/atomically/query_service.rb +++ b/lib/atomically/query_service.rb @@ -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