lhs
lhs copied to clipboard
Chain#all leaks endpoints hash
Consider the following cases:
authenticated(EntryFeedback::Base).where(place_id: listing.id, with_accepted_review: true).to_a
=>
[
EntryFeedback::Base#70223185154440(...),
EntryFeedback::Base#70223185154441(...),
EntryFeedback::Base#70223185154442(...)
]
vs.
authenticated(EntryFeedback::Base).where(place_id: listing.id, with_accepted_review: true).all
Expected:
- an array of records (a.k.a. enforcing the chain to resolve)
Got:
{":datastore/v2/places/:place_id/feedbacks"=>EntryFeedback::Base,
":datastore/v2/places/:place_id/feedback-summary"=>EntryFeedbackSummary::Base,
":datastore/v2/localch-accounts/:user_id/favorites"=>Favorite,
":datastore/v2/localch-accounts/:user_id/favorites/:id"=>Favorite,
":datastore/v2/favorites"=>Favorite,
":datastore/v2/favorites/:id"=>Favorite,
":datastore/v2/places"=>Place,
":datastore/v2/places/:id"=>Place,
":datastore/v2/spamnumbers"=>Spamnumber,
":datastore/v2/telemarketing-complaints"=>TelemarketingComplaint}
Discovered in: https://github.com/local-ch/location-app/tree/display-reviews
You are aware that there is a huge difference between to_a
and all
in combination with chains?
If your chain results to 4000 records on the BE to_a
will give you the first page as an array.
all
would paginate through all pages in order to return you all 4000 records from the BE in an array.
You are aware @Averethel ?
@pape-io yes, it's pretty clear that all
and to_a
are not equivalent, and if you use all
you need to know what you are doing. It's especially useful for prototyping / debugging / testing and I imagine that would be the main use case.
In any case, I would expect it behave the same way as ActiveRecord
does and definitely not to leak internals.
btw. this is exactly how I stumbled upon this one => I played around...
Leaking the internal is clearly a bug I will fix, just wanted to check if you are aware what all
is doing, because usually batch processing with find_each
is more likely to end up on 'production'