-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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 find_in_batches against string IDs when start option is not specified #8073
Fix find_in_batches against string IDs when start option is not specified #8073
Conversation
assert_kind_of Subscriber, subscriber | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong indent.
It needs a changelog entry as well. thanks. |
Thanks for pointing those details. |
@@ -136,4 +136,13 @@ def test_find_in_batches_should_use_any_column_as_primary_key | |||
|
|||
assert_equal nick_order_subscribers[1..-1].map(&:id), subscribers.map(&:id) | |||
end | |||
|
|||
def test_find_in_batches_should_use_any_column_as_primary_key_when_start_is_not_specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is still bad indented.
This will need a rebase since github says it cannot be automatically merged anymore, and please squash your commits. Thanks! |
Sorry for the poor indentation. I just rebased master into that branch and squashed my commits :) |
…_option Fix find_in_batches against string IDs when start option is not specified
@alexisbernard thanks. |
Awesome, thanks for the merge. |
Hi,
Here is a fix for find_in_batches when Model#id is a string. In fact when calling find_in_batches (or find_each) without the start option it generates a wrong SQL statement:
That statement is invalid with strict databases such as PostgreSQL, because it tries to compare a string against an integer.
With more tolerant databases such as SQLite it's passing, but in fact it skips IDs starting with a lower character than '0'.
Once accepted and merged, I plan to backport that fix in pull request #7987 for rails 3.2.
cc @spastorino