--- tests/Zend/Db/Select/StaticTest.php (revision 23226) +++ tests/Zend/Db/Select/StaticTest.php (working copy) @@ -603,6 +603,19 @@ } /** + * @group ZF-10589 + */ + public function testHavingZero() + { + $select = $this->_select() + ->columns(array('count' => 'COUNT(*)')) + ->group('bug_id'); + + $select->having('COUNT(*) > ?', 0); + $this->assertEquals('SELECT "zfproducts".*, COUNT(*) AS "count" FROM "zfproducts" GROUP BY "bug_id" HAVING (COUNT(*) > 0)', $select->__toString()); + } + + /** * Test adding an ORDER BY clause to a Zend_Db_Select object. */ Index: library/Zend/Db/Select.php =================================================================== --- library/Zend/Db/Select.php (revision 23226) +++ library/Zend/Db/Select.php (working copy) @@ -532,7 +532,7 @@ */ public function having($cond, $value = null, $type = null) { - if ($value) { + if ($value !== null) { $cond = $this->_adapter->quoteInto($cond, $value, $type); } @@ -559,7 +559,7 @@ */ public function orHaving($cond, $value = null, $type = null) { - if ($value) { + if ($value !== null) { $cond = $this->_adapter->quoteInto($cond, $value, $type); }