Changeset 10543
- Timestamp:
- 07/31/08 16:58:19 (4 months ago)
- Files:
-
- plugins/sfPropelFinderPlugin/README (modified) (1 diff)
- plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php (modified) (1 diff)
- plugins/sfPropelFinderPlugin/test/unit/sfPropelFinderRelationsTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelFinderPlugin/README
r10542 r10543 608 608 === 2008-07-31 | Trunk === 609 609 610 * francois: Fixed problem with table alias and PostgreSQL (based on a patch by mrhyde) 610 611 * mrhyde: Fixed problem with group by clauses being ripped off by pager 611 612 * francois: Implemented `DbFinder::toArray()`, `DbFinder::__toString()` and `DbFinder::toHtml()` plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php
r10542 r10543 517 517 foreach($this->getWithColumns() as $alias => $column) 518 518 { 519 $c->addAsColumn('\''.$alias.'\'', $column['column']); 519 if(strpos($alias, '.') !== false) 520 { 521 // The alias contains a forbidden character, so we must quote it 522 $alias = '"'.$alias.'"'; 523 } 524 $c->addAsColumn($alias, $column['column']); 520 525 } 521 526 plugins/sfPropelFinderPlugin/test/unit/sfPropelFinderRelationsTest.php
r10540 r10543 79 79 $con = Propel::getConnection(); 80 80 81 $t = new lime_test(7 8, new lime_output_color());81 $t = new lime_test(79, new lime_output_color()); 82 82 83 83 $t->diag('findRelation()'); … … 402 402 $comment->save(); 403 403 404 $ comment= sfPropelFinder::from('Comment')->404 $finder = sfPropelFinder::from('Comment')-> 405 405 join('Article')-> 406 withColumn('Article.Title') ->407 findOne();406 withColumn('Article.Title'); 407 $comment = $finder->findOne(); 408 408 $t->is($comment->getColumn('Article.Title'), 'bbbbb', 'Additional columns added with withColumn() are stored in the object and can be retrieved with getColumn()'); 409 $t->is($finder->getLatestQuery(), 'SELECT comment.ID, comment.CONTENT, comment.ARTICLE_ID, comment.AUTHOR_ID, article.TITLE AS "Article.Title" FROM comment, article WHERE comment.ARTICLE_ID=article.ID LIMIT 1', 'Columns added with withColumn() can contain a dot (and are then escaped with double quotes in SQL)'); 409 410 410 411 $comment = sfPropelFinder::from('Comment')-> … … 466 467 orderBy('NbComments'); 467 468 $article = $finder->findOne(); 468 $t->is($finder->getLatestQuery(), 'SELECT article.ID, article.TITLE, article.CATEGORY_ID, COUNT(comment.ID) AS \'NbComments\'FROM article, comment WHERE article.ID=comment.ARTICLE_ID GROUP BY article.ID ORDER BY NbComments ASC LIMIT 1', 'Columns added with withColumn() can be used for sorting');469 $t->is($finder->getLatestQuery(), 'SELECT article.ID, article.TITLE, article.CATEGORY_ID, COUNT(comment.ID) AS NbComments FROM article, comment WHERE article.ID=comment.ARTICLE_ID GROUP BY article.ID ORDER BY NbComments ASC LIMIT 1', 'Columns added with withColumn() can be used for sorting');