On Mar 18, 11:59 am, Jeremy Evans <[email protected]> wrote:
> On Mar 18, 11:47 am, David Lee <[email protected]> wrote:
>
> > Shouldn't #each implicitly do what #all does (set up all associations)
> > before returning? I really think all.each and each should behave
> > exactly the same.
>
> No, it shouldn't.  each has always yielded each record to its block as
> soon as it is yielded by the adapter, and all has always consumed all
> records before yielding/returning.  Making each act like all would
> cause problems.

Of course, when the block is yielded would be different. By "set up
all associations," I meant, "wrap the returned object in an Item
object and link all associated objects." I'm sorry it wasn't clear.

>
> You don't need to use all.each, Dataset#all takes a block.  Do you
> have some aversion to saving a character? ;p

Thanks, I didn't know all took a block; that's helpful to know.

Sequel should adhere to POLS, but I was surprised that all.each and
each yielded different objects. I was especially surprised because
Item.each, Item.filter.each, Item.dataset.each, Item.join(...).each,
and even Item.eager_graph().each all yield Item objects, but
Item.eager_graph(:user).each yields Hash objects.

Item.eager_graph(...).each should yield Item objects for consistency's
sake and not doing so should be considered a bug.

If we have to trade off between timing of the yields and the
properness of the parameters passed to the yields, we should prefer
the properness of the parameters.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to