Relation#each_batch doesn't respect limited datasets
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start at the Relation#each_batch implementation and reproduce the issue with a limited relation such as users.limit(10) and a batch size of 10. Trace how the relation is used while batching, then ensure the existing limit remains effective; done means only the limited rows are processed.
Written by the indexing model from the issue text.
Description
Describe the bug
When using Relation#each_batch, if you pass in a relation that already has a limit applied, Relation#each_batch will not respect it and process the batches as if the limit did not exist.
To Reproduce
users = ROM.env.relations[:users]
1000.times { create_user }
top_100 = users.limit(10)
i = 0
top_100.each_batch(size: 10) do |batch|
i += 1
raise 'This is unexpected...' if i > 10
end
Expected behavior
Relation#each_batch should respect the passed in limit, ideally by wrapping the input dataset in a subquery such that it will not be manipulated.
Your environment
- Affects my production application: YES
- Ruby version: 2.6.2
- OS: Linux
- Dominant language
- Ruby
- Stars
- 220
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rom-rb/rom-sql
-
bug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
バグ
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
voxpupuli/puppet-epel#186 · 1 comment ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) OpenBug Frontend
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TheOdinProject/curriculum#31402 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100