Development

Changeset 10542

You must first sign up to be able to contribute.

Changeset 10542

Show
Ignore:
Timestamp:
07/31/08 16:25:25 (4 months ago)
Author:
francois
Message:

sfPropelFinderPlugin Fixed problem with group by clauses being ripped off by pager (based on a patch from mrhyde) (closes #4038)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelFinderPlugin/README

    r10540 r10542  
    608608=== 2008-07-31 | Trunk === 
    609609 
     610 * mrhyde: Fixed problem with group by clauses being ripped off by pager 
    610611 * francois: Implemented `DbFinder::toArray()`, `DbFinder::__toString()` and `DbFinder::toHtml()` 
    611612 * francois: Implemented `sfDoctrineFinder::findBy()`, `findOneBy()`, `findPk()`, and initialized `where()` 
  • plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php

    r10344 r10542  
    10551055  } 
    10561056   
     1057  /** 
     1058   * Cloning instance should clone its components. 
     1059   *   
     1060   * Solves problems with sfPropelFinderPager.  
     1061   */  
     1062  public function __clone() 
     1063  {  
     1064    $this->criteria = clone $this->criteria; 
     1065  } 
     1066   
    10571067  public function __call($name, $arguments) 
    10581068  { 
  • plugins/sfPropelFinderPlugin/lib/sfPropelFinderPager.php

    r10047 r10542  
    1818  } 
    1919 
     20 
     21  /** 
     22   * Set finder object for the pager 
     23   * 
     24   * @param sfPropelFinder $finder 
     25   * @return void 
     26   */ 
     27  public function setFinder($finder) 
     28  { 
     29    $this->finder = $finder; 
     30  } 
     31   
    2032  /** 
    2133   * Get the finder for the pager 
     
    4759  { 
    4860    return $this->connection; 
    49   } 
    50  
    51   /** 
    52    * Set finder object for the pager 
    53    * 
    54    * @param sfPropelFinder $finder 
    55    * @return void 
    56    */ 
    57   public function setFinder($finder) 
    58   { 
    59     $this->finder = $finder; 
    6061  } 
    6162 
  • plugins/sfPropelFinderPlugin/test/unit/sfPropelFinderPagerTest.php

    r10047 r10542  
    5151ArticlePeer::doDeleteAll(); 
    5252 
    53 $t = new lime_test(27, new lime_output_color()); 
     53$t = new lime_test(29, new lime_output_color()); 
    5454 
    5555$article1 = new Article(); 
     
    127127$t->is($pager->getLastPage(), 2, 'sfPropelFinder::paginate() sfPropelFinder::paginate() uses the internal conditions'); 
    128128$t->is($pager->getFirstIndice(), 1, 'sfPropelFinder::paginate() sfPropelFinder::paginate() uses the internal conditions'); 
     129 
     130$t->diag('sfPropelFinderPager issues with GroupBy'); 
     131$finder = sfPropelFinder::from('Article')->groupBy('Title'); 
     132$pager = new sfPropelFinderPager('Article', 2); 
     133$pager->setFinder($finder); 
     134$pager->init(); 
     135$t->is($con->getLastExecutedQuery(), 'SELECT COUNT(article.ID) FROM article', 'sfPropelFinderPager::init() removes groupBy clauses and issues a count()'); 
     136$pager->getResults(); 
     137$t->is($con->getLastExecutedQuery(), 'SELECT article.ID, article.TITLE, article.CATEGORY_ID FROM article GROUP BY article.TITLE LIMIT 2', 'sfPropelFinderPager::getResults() does not remove groupBy clauses and issues a elect()');