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

Support touch_all in batches #51785

Merged
merged 1 commit into from May 13, 2024
Merged

Conversation

fatkodima
Copy link
Member

Currently, ActiveRecord is missing the ability to run touch_all via batches (compared to update_all/delete_all/etc).

Post.in_batches.touch_all

@byroot byroot merged commit 007a609 into rails:main May 13, 2024
2 of 4 checks passed
assert_queries_count(6 + 6) do # 6 selects, 6 updates
Developer.in_batches(of: 2).touch_all(time: time)
end
assert_equal Developer.all.pluck(:updated_at), [time] * Developer.count
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

assert_equal(
  [time] * Developer.count,
  Developer.all.pluck(:updated_at)
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.

@fatkodima fatkodima deleted the touch_all-in-batches branch May 13, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants