Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use update instead of update_all in the reserve_with_scope_using_optimized_mysql method. #198

Open
M-Yamashita01 opened this issue Sep 25, 2021 · 0 comments

Comments

@M-Yamashita01
Copy link

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

count = ready_scope.limit(1).update_all(locked_at: now, locked_by: worker.name)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant