Changeset 2475

Show
Ignore:
Timestamp:
06/02/08 02:15:39 (21 months ago)
Author:
fumiakiy
Message:

Group_by methods now returns an iterator that can be finished early. BugId:79888

Location:
branches/release-39
Files:
3 modified

Legend:

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

    r2473 r2475  
    201201    my $i = 0; 
    202202    return sub { 
     203        if (@_ && ($_[0] eq 'finish')) { 
     204            if ($sth) { 
     205                $sth->finish; 
     206                $driver->end_query($sth); 
     207            } 
     208            undef $sth; 
     209            return; 
     210        } 
     211 
    203212        unless ($sth->fetch && defined $count && (!defined $limit || ($i < $limit))) { 
    204213            $sth->finish; 
  • branches/release-39/t/41-atom.t

    r2457 r2475  
    416416    #print "$_\n" foreach @{$p->query_log}; 
    417417    my ( $count, $eid ) = $iter->(); 
    418     # finish iterator cleanly 
    419     while ( my @dump = $iter->() ) {} 
     418    $iter->('finish'); 
    420419 
    421420    my $entry = MT::Entry->load($eid); 
     
    575574        } 
    576575    } 
    577     # finish iterator cleanly 
    578     while ( my @dump = $iter->() ) {} 
     576    $iter->('finish'); 
    579577    die unless $eid; 
    580578 
  • branches/release-39/t/driver-tests.pl

    r2286 r2475  
    404404    }, { 
    405405        group => [ 'foo_id' ], 
    406         sort => 'foo_id desc', 
     406        sort => 'foo_id', 
     407        direction => 'descend', 
    407408    }); 
    408409my ($count, $bfid, $month); 
     
    418419$cgb_iter = Bar->count_group_by(undef, { 
    419420        group => [ 'extract(month from created_on)' ], 
    420         sort => 'extract(month from created_on) desc', 
     421        sort => 'extract(month from created_on)', 
     422        direction => 'descend', 
    421423    }); 
    422424isa_ok($cgb_iter, 'CODE');