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

Fix batch methods for historical models #324

Merged
merged 1 commit into from
Aug 13, 2024
Merged

Conversation

tagliala
Copy link
Member

In the default implementation, cursor defaults to primary_key, which is 'id'.
However, for historical models, we need to use 'hid' instead of 'id'.

This patch addresses an issue where with_hid_pkey is called after the cursor is already set, potentially leading to incorrect behavior.

Notes:

  • find_each and find_in_batches use in_batches internally, however this is not enough anymore in the upcoming Rails 8.0 because there is a conditional branch using enum_for
  • This approach prevents specifying 'id' as a cursor for historical models. If 'id' is needed, it must be handled separately.

Fix #321

In the default implementation, `cursor` defaults to `primary_key`, which
is 'id'.
However, for historical models, we need to use 'hid' instead of 'id'.

This patch addresses an issue where `with_hid_pkey` is called after the
cursor is already set, potentially leading to incorrect behavior.

Notes:
- `find_each` and `find_in_batches` use `in_batches` internally, however
  this is not enough anymore in the upcoming Rails 8.0 because there is
  a conditional branch using `enum_for`
- This approach prevents specifying 'id' as a cursor for historical
  models. If 'id' is needed, it must be handled separately.

Fix #321
@tagliala tagliala merged commit 28daff8 into master Aug 13, 2024
19 of 20 checks passed
@tagliala tagliala deleted the feature/321-find-each-edge branch August 13, 2024 07:18
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.

Rails edge: Find each broken
1 participant