You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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=0top_100.each_batch(size: 10)do |batch|
i += 1raise'This is unexpected...'ifi > 10end
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
The text was updated successfully, but these errors were encountered:
That's good as well. The subquery is nice because you do not have to worry about twiddling around calculating the correct limits, and the user would not have to worry bout accidentally overriding the limit after the batch is yielded. However, it would add some complexity w/r/t remapping the current current clauses (i.e. making sure the exact same where clauses, etc) are added back to the yielded dataset. Either option is an improvement :)
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
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
The text was updated successfully, but these errors were encountered: