Changeset 101

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

r104@crucially-3 (orig r1088): ykerherve | 2006-01-30 14:41:34 -0800
Fixed a nasty bug where the Driver modifies the $term passed in arguments for '-and'
so if you reused $terms twice, -and gets transformed to a -or


Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/Data/ObjectDriver/SQL.pm

    r99 r101  
    8484    if (ref($val) eq 'ARRAY') { 
    8585        my $logic = 'OR'; 
     86        my @val = @$val; 
    8687        if ($val->[0] eq '-and') { 
    8788            $logic = 'AND'; 
    88             shift @$val; 
     89            shift @val; 
    8990        } 
    9091        my @terms; 
    91         for my $val (@$val) { 
     92        for my $val (@val) { 
    9293            my($term, $bind) = $stmt->_mk_term($col, $val); 
    9394            push @terms, $term; 
  • trunk/t/11-sql.t

    r86 r101  
    44 
    55use Data::ObjectDriver::SQL; 
    6 use Test::More tests => 49; 
     6use Test::More tests => 51; 
    77 
    88my $stmt = ns(); 
     
    128128is($stmt->bind->[2], 'baz'); 
    129129 
     130## regression bug. modified parameters 
     131my %terms = ( foo => [-and => 'foo', 'bar', 'baz']); 
     132$stmt = ns(); 
     133$stmt->add_where(%terms); 
     134is($stmt->as_sql_where, "WHERE (foo = ? AND foo = ? AND foo = ?)\n"); 
     135$stmt->add_where(%terms); 
     136is($stmt->as_sql_where, "WHERE (foo = ? AND foo = ? AND foo = ?) AND (foo = ? AND foo = ? AND foo = ?)\n"); 
     137 
    130138$stmt = ns(); 
    131139$stmt->add_select(foo => 'foo');