On Thu, Mar 12, 2009 at 14:27, David Ihnen <[email protected]> wrote:
> I think that makes it more clear.  Given the proper relationships set up
> couldn't that just be something like...
>
> sub elapsed_ms {
> my $self = shift;
> my $id = shift;
> $self->search(
>   { me.id => $id },
>   { +select => [ \"datediff(millisecond, logparents.date, logstatus.date)" ]
>   , +as => [ elapsed ]
>   , prefetch => [ 'logstatus', 'logchildren' ]
>   , order_by => 'logstatus.date desc'
>   })->first->get_column->('elapsed');
> }

Use join instead of prefetch unless you actually need the
optimization. In this case, you don't.

Prefetch still has some bugs in it that rear their ugly heads in odd places.

Rob

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to