Show
Ignore:
Timestamp:
06/08/08 15:50:10 (21 months ago)
Author:
guilhermeblanco
Message:

Fixed #1049. Updated wrong method name in ticket 930.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Query/JoinCondition.php

    r4366 r4493  
    4040 
    4141        if (count($e) > 2) { 
     42            $expr = new Doctrine_Expression($e[0], $this->query->getConnection()); 
     43            $e[0] = $expr->getSql(); 
     44 
     45            $operator  = $e[1]; 
     46 
     47            $expr = new Doctrine_Expression($e[2], $this->query->getConnection()); 
     48            $e[2] = $expr->getSql(); 
     49 
     50            // We need to check for agg functions here 
     51            $hasLeftAggExpression = preg_match('/(.*)\(([^\)]*)\)([\)]*)/', $e[0], $leftMatches); 
     52 
     53            if ($hasLeftAggExpression) { 
     54                $e[0] = $leftMatches[2]; 
     55            } 
     56 
     57            $hasRightAggExpression = preg_match('/(.*)\(([^\)]*)\)([\)]*)/', $e[2], $rightMatches); 
     58 
     59            if ($hasRightAggExpression) { 
     60                $e[2] = $rightMatches[2]; 
     61            } 
     62 
    4263            $a         = explode('.', $e[0]); 
    4364            $field     = array_pop($a); 
    4465            $reference = implode('.', $a); 
    45             $operator  = $e[1]; 
    4666            $value     = $e[2]; 
    4767 
     
    104124                    } 
    105125                default: 
    106                     $condition  = $alias . '.' . $field . ' ' 
    107                                 . $operator . ' ' . $value; 
     126                    $leftExpr = (($hasLeftAggExpression) ? $leftMatches[1] . '(' : '')  
     127                              . $alias . '.' . $field 
     128                              . (($hasLeftAggExpression) ? $leftMatches[3] . ')' : '') ; 
     129 
     130                    $rightExpr = (($hasRightAggExpression) ? $rightMatches[1] . '(' : '')  
     131                              . $value 
     132                              . (($hasRightAggExpression) ? $rightMatches[3] . ')' : '') ; 
     133 
     134                    $condition  = $leftExpr . ' ' . $operator . ' ' . $rightExpr; 
    108135            } 
    109136 
    110137        } 
     138 
    111139        return $condition; 
    112140    }