Skip to content

Add update_on option to batch_update - #26

Merged
quentindemetz merged 5 commits into
mainfrom
fr/batch_update-update-on
May 22, 2026
Merged

quentindemetz merged 5 commits into
mainfrom
fr/batch_update-update-on

Conversation

@frodsan

@frodsan frodsan commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

I noticed the following pattern in our codebase:

Model.batch_update_statements(
  to_update,
  update_on: %I[foreign_key_id],
).each { Model.connection.execute(_1) }

This adds an update_on keyword argument to batch_update, allowing callers to specify which columns to use for matching records instead of always defaulting to the primary key. I'd prefer to write the previous code like:

Model.batch_update(to_update, update_on: %I[foreign_key_id], columns: %I[...])

@quentindemetz quentindemetz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

@quentindemetz
quentindemetz merged commit d244b50 into main May 22, 2026
6 checks passed
@quentindemetz
quentindemetz deleted the fr/batch_update-update-on branch May 22, 2026 12:48
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

Successfully merging this pull request may close these issues.

2 participants