Re: Lazy population of has_a child records
[prev]
[thread]
[next]
[Date index for 2005/06/08]
--- Christopher Laco <mendlefarg@xxxxx.xxx> wrote:
> This is roughly:
>
> my $cart = Handle::Cart->new(...);
> my $cart->add_to_items({
> id => 123456,
> sku => 'sku1',
> price => 1.23
> });
>
> my $order = Handel::Order->new($cart);
>
> [behind the scenees in new]
> my $items = $cart->items;
> while (my $item = $items->next) {
> my %copy = %{$item};
>
> # reset some values, do some calulations
> ....
> # add copy of cart item into order items
> $self->add_to_items(\%copy);
> };
> https://secure.cafes.net/billing/Staff_/Punch/add.pl
>
> No, much to my surprise, %copy is empty except for id eve though the
> items class has:
>
> __PACKAGE__->columns(Essential => qw(id cart sku price));
>
> Of course if I call something first:
>
>
> [behind the scenees in new]
> my $items = $cart->items;
> while (my $item = $items->next) {
> $item->sku; #this loads the data
> my %copy = %{$item};
>
> # reset some values, do some calulations
> ....
> # add copy of cart item into order items
> $self->add_to_items(\%copy);
> };
>
>
> %copy now has all of the key/values. Does this mean that lazy
> population and stopping it via Essential only works on the class you
> are directly working with, and not child record classes returned via
> has_a/has_many?
The has_many method "items" that you call internally does an
"ItemClass->search(...)" which does an sql_Retrieve which selects essential
cols. So lazy popping should work here. From reading docs i believe it is
intended to be ubiquitous. What happens if you don't don't use an iterator
and use a array assignment instead?
pjs
__________________________________
Discover Yahoo!
Find restaurants, movies, travel and more fun for the weekend. Check it out!
http://discover.yahoo.com/weekend.html
|
|
Re: Lazy population of has_a child records
Peter Speltz 04:10 on 08 Jun 2005
|