tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

`find_in_batches` return type is wrong

Open dshearer opened this issue 8 months ago • 3 comments
trafficstars

Hi! Here, the return type for find_in_batches is set as T::Enumerator[T::Enumerator[A]], but I believe the actual return type is T::Enumerator[T::Array[A]].

This is implied in the documentation:

Yields each batch of records that was found by the find options as an array.

And I've checked this at runtime:

MyModel.find_in_batches.map do |batch|
  T.let(batch, T::Enumerator[MyModel]) # This fails
end

This is with Tapioca 0.16.11, Sorbet 0.5.11934, and Rails 8.1.0.alpha.

dshearer avatar Mar 19 '25 18:03 dshearer

@dshearer Thanks for the report! We'd be happy to review a PR fixing this issue if you have time to look into it.

egiurleo avatar Apr 21 '25 15:04 egiurleo

Hi @egiurleo , I'd like to take a crack at this if it is still available?

drewhoffer avatar Jun 15 '25 20:06 drewhoffer

@drewhoffer Sorry for the slow response -- yes! Go ahead.

egiurleo avatar Jun 25 '25 18:06 egiurleo