tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

Add support for `cursor:` when using `in_batches` on an ActiveRecord PrivateRelation

Open SamuelDev opened this issue 2 years ago • 4 comments

In 8.0 rails added support for a custom cursor when calling in_batches on a relation. RBI files generated by tapioca do not currently generate this field.

Rails version: 8.1.0 tapioca version: 0.16.3

SamuelDev avatar Nov 22 '24 17:11 SamuelDev

Hi @SamuelDev, what's the expected type of this cursor?

Would you like to open a PR to modify one of the sigs here:

https://github.com/Shopify/tapioca/blob/0a9f29181270905363d472a041b16443f20bd1a4/lib/tapioca/dsl/compilers/active_record_relations.rb#L917-L952

amomchilov avatar Nov 25 '24 18:11 amomchilov

It is a column name or array of column names. Symbols, possibly strings, unsure of that specific technicality.

SamuelDev avatar Nov 25 '24 21:11 SamuelDev

T.any(String, Symbol) might be a good first approximation. If other types are possible, we can widen the type in the future. It looks like it can be either a single value, or an array of values (it's passed into Array), so perhaps it should be:

T.any(String, Symbol, T::Array[T.any(String, Symbol)])

I won't be able to investigate this myself any time soon, but if you confirm that it works and open a PR, I'd be happy to review and merge

amomchilov avatar Nov 25 '24 21:11 amomchilov

I have this open PR: https://github.com/Shopify/tapioca/pull/2315

lavoiesl avatar Jun 12 '25 17:06 lavoiesl