Allow to have non-distinct queries
This commit is contained in:
parent
261eacdbfc
commit
67c1e1d2b1
@ -701,6 +701,18 @@ abstract class AbstractQuery
|
|||||||
return isset($this->_hints[$name]) ? $this->_hints[$name] : false;
|
return isset($this->_hints[$name]) ? $this->_hints[$name] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the query has a hint
|
||||||
|
*
|
||||||
|
* @param string $name The name of the hint
|
||||||
|
*
|
||||||
|
* @return bool False if the query does not have any hint
|
||||||
|
*/
|
||||||
|
public function hasHint($name)
|
||||||
|
{
|
||||||
|
return isset($this->_hints[$name]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the key value map of query hints that are currently set.
|
* Return the key value map of query hints that are currently set.
|
||||||
*
|
*
|
||||||
|
@ -121,7 +121,7 @@ class Paginator implements \Countable, \IteratorAggregate
|
|||||||
/* @var $countQuery Query */
|
/* @var $countQuery Query */
|
||||||
$countQuery = $this->cloneQuery($this->query);
|
$countQuery = $this->cloneQuery($this->query);
|
||||||
|
|
||||||
if ( ! $countQuery->getHint(CountWalker::HINT_DISTINCT)) {
|
if ( ! $countQuery->hasHint(CountWalker::HINT_DISTINCT)) {
|
||||||
$countQuery->setHint(CountWalker::HINT_DISTINCT, true);
|
$countQuery->setHint(CountWalker::HINT_DISTINCT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,8 @@ class QueryTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertEquals('bar', $q->getHint('foo'));
|
$this->assertEquals('bar', $q->getHint('foo'));
|
||||||
$this->assertEquals('baz', $q->getHint('bar'));
|
$this->assertEquals('baz', $q->getHint('bar'));
|
||||||
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints());
|
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints());
|
||||||
|
$this->assertTrue($q->hasHint('foo'));
|
||||||
|
$this->assertFalse($q->hasHint('barFooBaz'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user