Show
Ignore:
Timestamp:
05/04/06 00:07:56 (4 years ago)
Author:
sky
Message:

r101@crucially-3 (orig r1085): mpaschal | 2006-01-13 13:09:03 -0800
Use DBD's column name decoration in ORDER BY clauses too
(Is this right? When does a class have no datasource?)


Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/Data/ObjectDriver/Driver/DBI.pm

    r97 r98  
    473473            } 
    474474        } 
     475 
     476        ## Set statement's ORDER clause if any. 
     477        if ($args->{sort} || $args->{direction}) { 
     478            my $order = $args->{sort} || 'id'; 
     479            my $dir = $args->{direction} && 
     480                      $args->{direction} eq 'descend' ? 'DESC' : 'ASC'; 
     481            $stmt->order({ 
     482                column => $dbd->db_column_name($tbl, $order), 
     483                desc   => $dir, 
     484            }); 
     485        } 
    475486    } 
    476487    $stmt->limit($args->{limit}) if $args->{limit}; 
    477488    $stmt->offset($args->{offset}) if $args->{offset}; 
    478     if ($args->{sort} || $args->{direction}) { 
    479         my $order = $args->{sort} || 'id'; 
    480         my $dir = $args->{direction} && 
    481                   $args->{direction} eq 'descend' ? 'DESC' : 'ASC'; 
    482         $stmt->order({ 
    483             column => $order, 
    484             desc   => $dir, 
    485         }); 
    486     } 
    487489    $stmt; 
    488490}