You are right. At first what I needed was to automatically eager load 
associations, and that I'm free later to return #all or just #first 
(because of that "include" parameter), and then it surprised me that after 
calling #first the eager loading dissapeared.

But tactical_eager_loading solves my use case perfectly. I can't believe 
how the implementation of that plugin is simple. Let's compare it to 
ActiveRecord's 
equivalent <https://github.com/salsify/goldiloader>, lol.

On Friday, May 15, 2015 at 4:59:50 AM UTC+2, Jeremy Evans wrote:
>
> On Thursday, May 14, 2015 at 3:56:19 PM UTC-7, Janko Marohnić wrote:
>>
>> And eager_graph works normally with Dataset#first as is currently 
>> implemented? Yes, usually you don't have to eager load, unless you have 
>> associations more than one level deep, then you need it.
>>
>
> No, eager_graph is designed to be used with #all, and returns plain hashes 
> if called with each (or first which calls each).  Basically, if you use 
> eager or eager_graph, you should call #all.  If you know you are only 
> loading a single record, don't eager load.  If you are loading a single 
> current record and want to eager load nested associated records, do the 
> eager loading just for the associated records (e.g. by passing a block to 
> the association method), don't attempt to eager load for the single record.
>
> 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/d/optout.

Reply via email to