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