Closed nepalez closed 4 years ago
Thanks for the idea. I hadn't realized the subtle difference between Enumerable and Enumerator. 😄
It seems like a great idea, but removes the ability to process procedurally. The cursor returned can be called with cursor.fetch
to return the next row, which is useful for doing merges, or processing involving different streams of data.
Unfortunately, I'll have to back out this change. I don't want to break this feature, as I use it 😅
Won't it be more natural for the
each_instance
method (as well as other iterators) w/o a block to return a enumerator instead of the "raw" cursor?Now I can do this explicitly:
I think this
to_enum
can be applied to cursor under the hood, namely here: https://github.com/afair/postgresql_cursor/blob/master/lib/postgresql_cursor/active_record/sql_cursor.rb#L34This would make API a bit more natural IMHO: