delayed_job_active_record icon indicating copy to clipboard operation
delayed_job_active_record copied to clipboard

Use `update` instead of `update_all` in the reserve_with_scope_using_optimized_mysql method.

Open M-Yamashita01 opened this issue 3 years ago • 0 comments

Hello, I read the code in the reserve_with_scope_using_optimized_mysql method and found the following code.

https://github.com/collectiveidea/delayed_job_active_record/blob/d65b0f9900f5b0c78c341c7c0209c2d138d64ec5/lib/delayed/backend/active_record.rb#L148

We think that the return value of ready_scope.limit(1) is ActiveRecord::Relation and ActiveRecord::Relation has update method in addition to update_all method in Rails 3 and later. In addition, the target record of ready_scope.limit(1) to be updated is only one record.

Therefore, we think you can use update instead of update_all. Could you please tell me why you are using the update_all method?

Thank you.

M-Yamashita01 avatar Sep 25 '21 08:09 M-Yamashita01