Changeset 4493
- Timestamp:
- 06/08/08 19:50:10 (13 months ago)
- Location:
- branches/0.11
- Files:
-
- 3 modified
-
lib/Doctrine/Query/JoinCondition.php (modified) (2 diffs)
-
tests/Query/JoinTestCase.php (modified) (1 diff)
-
tests/Ticket/930TestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/lib/Doctrine/Query/JoinCondition.php
r4366 r4493 40 40 41 41 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 42 63 $a = explode('.', $e[0]); 43 64 $field = array_pop($a); 44 65 $reference = implode('.', $a); 45 $operator = $e[1];46 66 $value = $e[2]; 47 67 … … 104 124 } 105 125 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; 108 135 } 109 136 110 137 } 138 111 139 return $condition; 112 140 } -
branches/0.11/tests/Query/JoinTestCase.php
r4489 r4493 88 88 89 89 90 public function testQueryMultipleAggFunctionInJoins() 91 { 92 $q = new Doctrine_Query(); 93 94 $q->select('c.*, c2.*, d.*') 95 ->from('Record_Country c') 96 ->innerJoin('c.City c2 WITH LOWER(UPPER(c2.name)) LIKE LOWER(?)', array('city 1')) 97 ->where('c.id = ?', array(1)); 98 99 $this->assertEqual($q->getSql(), 'SELECT r.id AS r__id, r.name AS r__name, r2.id AS r2__id, r2.name AS r2__name, r2.country_id AS r2__country_id, r2.district_id AS r2__district_id FROM record__country r INNER JOIN record__city r2 ON r.id = r2.country_id AND LOWER(r2.name) LIKE LOWER(?) WHERE r.id = ?'); 100 } 101 102 90 103 public function testQuerySupportsCustomJoinsAndWithKeyword() 91 104 { -
branches/0.11/tests/Ticket/930TestCase.php
r4415 r4493 88 88 ->fetchArray(); 89 89 } catch (Exception $e) { 90 $this->fail($e->ge Message());90 $this->fail($e->getMessage()); 91 91 } 92 92 $this->assertEqual($queryCountBefore + 1, $this->conn->count());