From b9e16e5452fd916bd9444807ee32285d20218c8e Mon Sep 17 00:00:00 2001 From: ff2248 Date: Thu, 24 Aug 2023 23:12:20 +0800 Subject: [PATCH] replace from(nil) to from(Arel.sql(DUAL)) for to query from DUAL --- 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 e0cceb4..94d8d4b 100644 --- a/lib/atomically/query_service.rb +++ b/lib/atomically/query_service.rb @@ -88,7 +88,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(Arel.sql('@ids')).first + ids = @klass.from(Arel.sql('DUAL')).pluck(Arel.sql('@ids')).first end return ids.try{|s| s.split(',').map(&:to_i).uniq.sort } || [] # 將 id 從字串取出來 @id 的格式範例: '1,4,12' end