On Friday, February 28, 2014 6:36:56 AM UTC-8, Oldřich Vetešník wrote:
>
> I am wondering: why isn't eager() triggered on each? In a real application 
> I'm using each to list filtered, sorted and paged orders with user's name 
> and id but I noticed it's calling a query for each associated user. Here is 
> a simplifed test case that demonstrates it:
>

This is the expected and documented behavior.  You can't eager load if you 
don't have all values up front, and each iterates before all values are 
received.  The recommended approach is to use all instead of each.  If for 
some reason you must use each, you can use the eager_each plugin (which 
makes each call all internally).

The reason you see last(10) eager loading is calling last with an integer 
calls all internally (as it returns an array).

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to