Show
Ignore:
Timestamp:
05/29/08 17:22:32 (18 months ago)
Author:
bchoate
Message:

Adding support for a max_group_by method. BugId:79914

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-39/lib/MT/ObjectDriver/Driver/DBI.pm

    r2202 r2459  
    116116    $args->{direction} = 'descend' unless exists $args->{direction}; 
    117117    $driver->_do_group_by("AVG($avg_column) AS avg_$avg_column", @_); 
     118} 
     119 
     120sub max_group_by { 
     121    my $driver = shift; 
     122    my ($class, $terms, $args) = @_; 
     123 
     124    my $max_column = delete $args->{max}; 
     125    return unless $max_column; 
     126    $max_column = $driver->_decorate_column_name($class, $max_column); 
     127    $args->{sort} = "max_$max_column" unless exists $args->{sort}; 
     128    $args->{direction} = 'descend' unless exists $args->{direction}; 
     129    $driver->_do_group_by("MAX($max_column) AS max_$max_column", @_); 
    118130} 
    119131