Changeset 3945
- Timestamp:
- 03/08/08 03:26:14 (16 months ago)
- Location:
- branches/0.10
- Files:
-
- 5 modified
-
lib/Doctrine/Query.php (modified) (2 diffs)
-
lib/Doctrine/Table.php (modified) (1 diff)
-
tests/DoctrineTest/GroupTest.php (modified) (1 diff)
-
tests/Query/AggregateValueTestCase.php (modified) (3 diffs)
-
tests/run.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine/Query.php
r3928 r3945 397 397 return $this->getSqlAggregateAlias($dqlAlias); 398 398 } else { 399 throw new Doctrine_Query_Exception('Unknown aggregate alias: ' . $dqlAlias);399 throw new Doctrine_Query_Exception('Unknown aggregate alias: ' . $dqlAlias); 400 400 } 401 401 } … … 1435 1435 public function load($path, $loadFields = true) 1436 1436 { 1437 if (isset($this->_queryComponents[$path])) { 1438 return $this->_queryComponents[$path]; 1439 } 1437 if (isset($this->_queryComponents[$path])) { 1438 return $this->_queryComponents[$path]; 1439 } 1440 1440 1441 $e = $this->_tokenizer->quoteExplode($path, ' INDEXBY '); 1441 1442 -
branches/0.10/lib/Doctrine/Table.php
r3885 r3945 246 246 */ 247 247 public function initDefinition() 248 { 248 { 249 249 $name = $this->_options['name']; 250 250 if ( ! class_exists($name) || empty($name)) { -
branches/0.10/tests/DoctrineTest/GroupTest.php
r2999 r3945 50 50 } catch(Exception $e) { 51 51 $this->_failed += 1; 52 $this->_messages[] = 'Unexpected exception thrown with message [' . $e->getMessage() . '] in ' . $e->getFile() . ' on line ' . $e->getLine(); 52 $this->_messages[] = 'Unexpected exception thrown in [' . get_class($testCase) . '] with message [' . $e->getMessage() . '] in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n\nTrace\n-------------\n\n" . $e->getTraceAsString();; 53 53 54 } 54 55 $this->_passed += $testCase->getPassCount(); -
branches/0.10/tests/Query/AggregateValueTestCase.php
r3884 r3945 146 146 $q = new Doctrine_Query(); 147 147 148 $q->select('MAX(u.name) ')->from('User u')->leftJoin('u.Phonenumber p')->groupby('u.id');149 150 $this->assertEqual($q->getQuery(), 'SELECT MAX(e.name) AS e__0 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) GROUP BY e.id');148 $q->select('MAX(u.name), u.*, p.*')->from('User u')->leftJoin('u.Phonenumber p')->groupby('u.id'); 149 150 $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id, MAX(e.name) AS e__0 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) GROUP BY e.id'); 151 151 $users = $q->execute(); 152 152 … … 181 181 { 182 182 $q = new Doctrine_Query(); 183 $ func = $q->from('QueryTest_Item i')->parseFunctionExpression('SUM(i.price)');184 185 $this->assertEqual($ func, 'SUM(i.price)');183 $q->select('SUM(i.price)')->from('QueryTest_Item i'); 184 185 $this->assertEqual($q->getSql(), 'SELECT SUM(q.price) AS q__0 FROM query_test__item q'); 186 186 } 187 187 public function testAggregateFunctionParser2() 188 188 { 189 189 $q = new Doctrine_Query(); 190 $ func = $q->from('QueryTest_Item i')->parseFunctionExpression('SUM(i.price * i.quantity)');191 192 $this->assertEqual($ func, 'SUM(i.price * i.quantity)');190 $q->select('SUM(i.price * i.quantity)')->from('QueryTest_Item i'); 191 192 $this->assertEqual($q->getSql(), 'SELECT SUM(q.price * q.quantity) AS q__0 FROM query_test__item q'); 193 193 } 194 194 public function testAggregateFunctionParser3() 195 195 { 196 196 $q = new Doctrine_Query(); 197 $ func = $q->from('QueryTest_Item i')->parseFunctionExpression('MOD(i.price, i.quantity)');198 199 $this->assertEqual($ func, 'MOD(i.price, i.quantity)');197 $q->select('MOD(i.price, i.quantity)')->from('QueryTest_Item i'); 198 199 $this->assertEqual($q->getSql(), 'SELECT MOD(q.price, q.quantity) AS q__0 FROM query_test__item q'); 200 200 } 201 201 public function testAggregateFunctionParser4() 202 202 { 203 203 $q = new Doctrine_Query(); 204 $ func = $q->from('QueryTest_Item i')->parseFunctionExpression('CONCAT(i.price, i.quantity)');205 206 $this->assertEqual($ func, 'CONCAT(i.price, i.quantity)');204 $q->select('CONCAT(i.price, i.quantity)')->from('QueryTest_Item i'); 205 206 $this->assertEqual($q->getSql(), 'SELECT CONCAT(q.price, q.quantity) AS q__0 FROM query_test__item q'); 207 207 } 208 208 public function testAggregateFunctionParsingSupportsMultipleComponentReferences() … … 211 211 $q->select('SUM(i.price * i.quantity)') 212 212 ->from('QueryTest_Item i'); 213 213 214 214 $this->assertEqual($q->getQuery(), "SELECT SUM(q.price * q.quantity) AS q__0 FROM query_test__item q"); 215 215 } 216 217 218 216 } -
branches/0.10/tests/run.php
r3916 r3945 186 186 // Query tests 187 187 $query_tests = new GroupTest('Query tests','query_test'); 188 $query_tests->addTestCase(new Doctrine_Query_TestCase()); 188 189 $query_tests->addTestCase(new Doctrine_Query_Condition_TestCase()); 189 190 $query_tests->addTestCase(new Doctrine_Query_MultiJoin_TestCase());