DBIx::Class - Related Tables

Dave Cross dave at dave.org.uk
Tue Oct 7 06:32:18 BST 2008


Dagfinn Ilmari Mannsåker wrote:
> "Wallace Reis" <reis.wallace at gmail.com> writes:
> 
>> On Mon, Oct 6, 2008 at 5:59 PM, Dave Cross <dave at dave.org.uk> wrote:
>>> Given a distribution object, I want to find the highest version for
>>> which we have a successful build (or, to find out that there hasn't been
>>> a successful build).
>> my $main_build = $dist->builds->search_rs({
>>         'status' => 'success'
>> }, {
>>         'select' => [{ 'MAX' => 'version' }],
>>         'as'       => ['max_version'],
>>         'rows'   => '1'
>> })->single;
>>
>> print $main_build->get_column('max_version');
>>
>> (...)
>>
>> or
>>
>> my $main_build = $dist->builds->search_rs({
>>         'status' => 'success'
>> }, {
>>         'order_by' => 'version DESC',
>>         'rows'        => '1'
>> })->single;
>>
>> print $main_build->version;
> 
> or 
> 
> my $max_version = $dist->search_related( builds => { status => 'success' })
>                        ->get_column('version')->max;
> 

Fabulous. Thanks.

Dave...



More information about the london.pm mailing list