From 221d44a110db75131285b88e3167fdd13c8d7a16 Mon Sep 17 00:00:00 2001 From: Martin Keckeis Date: Fri, 15 Feb 2013 14:46:30 +0100 Subject: [PATCH 1/2] Update library/Zend/Paginator/Adapter/DbSelect.php Group by reset --- src/Adapter/DbSelect.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Adapter/DbSelect.php b/src/Adapter/DbSelect.php index d4a894e..4e97352 100644 --- a/src/Adapter/DbSelect.php +++ b/src/Adapter/DbSelect.php @@ -107,6 +107,7 @@ public function count() $select->reset(Select::LIMIT); $select->reset(Select::OFFSET); $select->reset(Select::ORDER); + $select->reset(Select::GROUP); $select->columns(array('c' => new Expression('COUNT(1)'))); From 8be3b981fa6047f89e17ef2c485ee4f269aed9d1 Mon Sep 17 00:00:00 2001 From: Ralph Schindler Date: Tue, 19 Feb 2013 16:07:59 -0600 Subject: [PATCH 2/2] Zend\Paginator Unit test for DbSelect and resetting of join columns --- src/Adapter/DbSelect.php | 4 +--- test/Adapter/DbSelectTest.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Adapter/DbSelect.php b/src/Adapter/DbSelect.php index 2f8b144..3919de1 100644 --- a/src/Adapter/DbSelect.php +++ b/src/Adapter/DbSelect.php @@ -109,12 +109,10 @@ public function count() $select->reset(Select::ORDER); $select->reset(Select::GROUP); - //get Joins + // get join information, clear, and repopulate without columns $joins = $select->getRawState(Select::JOINS); - //clear Joins $select->reset(Select::JOINS); foreach ($joins as $join) { - // Creates join without columns $select->join($join['name'], $join['on'], array(), $join['type']); } diff --git a/test/Adapter/DbSelectTest.php b/test/Adapter/DbSelectTest.php index fd781c7..ac21f28 100644 --- a/test/Adapter/DbSelectTest.php +++ b/test/Adapter/DbSelectTest.php @@ -62,7 +62,17 @@ public function testCount() { $this->mockSelect->expects($this->once())->method('columns')->with($this->equalTo(array('c' => new Expression('COUNT(1)')))); $this->mockResult->expects($this->any())->method('current')->will($this->returnValue(array('c' => 5))); - $this->mockSelect->expects($this->exactly(5))->method('reset'); // called for columns, limit, offset, order + + $this->mockSelect->expects($this->exactly(6))->method('reset'); // called for columns, limit, offset, order + $this->mockSelect->expects($this->once())->method('getRawState')->with($this->equalTo(Select::JOINS)) + ->will($this->returnValue(array(array('name' => 'Foo', 'on' => 'On Stuff', 'columns' => array('foo', 'bar'), 'type' => Select::JOIN_INNER)))); + $this->mockSelect->expects($this->once())->method('join')->with( + 'Foo', + 'On Stuff', + array(), + Select::JOIN_INNER + ); + $count = $this->dbSelect->count(); $this->assertEquals(5, $count); }