-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot "includes" other records when using this #25
Comments
This may be difficult, but it certainly would be nice to do. This library mostly performs the row fetching and returns each row as either a Hash or Model.instantiate(). It does this outside of ActiveRecord internals that work to map the database results back into Objects (like what an ORM does). I think it would be easier to introduce Cursors into ActiveRecord than do this :-) I'll leave this open in case some aspiring coder can put together a Pull Request, or if I have any ideas in the future. |
Hi, I created a simpler cursor (less features that is...) inspired by this cursor that supports the includes and works for our use case. I found that ActiveRecord used the This cursor is then used as follows: Cursor.new(Model.includes(foos: [:bar], :bar_foos).where(id < 10000000).order(:id)).find_each do |model|
# do something
end The entire cursor code is here: https://gist.github.com/lvonk/9fefe788616a22170bf53fadd7bcb66a Will this work in this gem you think? If so I could try to create a PR for this... |
I'm not sure how difficult it would be to do, but I realized
Model.includes(:something).each_instance
will return back records that do not have the associations preloaded.The text was updated successfully, but these errors were encountered: