From 3f112db7256994fc2284f011b4063d36b8614016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Gallego?= Date: Tue, 9 Jul 2013 17:31:30 +0200 Subject: [PATCH 1/2] Allow to have non-distinct queries --- lib/Doctrine/ORM/AbstractQuery.php | 12 ++++++++++++ lib/Doctrine/ORM/Tools/Pagination/Paginator.php | 2 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index b32310512..583969944 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -701,6 +701,18 @@ abstract class AbstractQuery 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. * diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index 115eb590e..2d45df95a 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -121,7 +121,7 @@ class Paginator implements \Countable, \IteratorAggregate /* @var $countQuery Query */ $countQuery = $this->cloneQuery($this->query); - if ( ! $countQuery->getHint(CountWalker::HINT_DISTINCT)) { + if ( ! $countQuery->hasHint(CountWalker::HINT_DISTINCT)) { $countQuery->setHint(CountWalker::HINT_DISTINCT, true); } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 9617fa873..adef91d4a 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -105,6 +105,8 @@ class QueryTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals('bar', $q->getHint('foo')); $this->assertEquals('baz', $q->getHint('bar')); $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints()); + $this->assertTrue($q->hasHint('foo')); + $this->assertFalse($q->hasHint('barFooBaz')); } /** From 13c1efb240dd0af25ad0abe230df98ec895892c7 Mon Sep 17 00:00:00 2001 From: J Bruni Date: Sat, 3 Aug 2013 11:26:37 -0300 Subject: [PATCH 2/2] Update basic-mapping.rst The attribute name is "name", not "column", isn't it? --- docs/en/reference/basic-mapping.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/basic-mapping.rst b/docs/en/reference/basic-mapping.rst index 2909048dd..6537b0b12 100644 --- a/docs/en/reference/basic-mapping.rst +++ b/docs/en/reference/basic-mapping.rst @@ -297,7 +297,7 @@ list: - ``type``: (optional, defaults to 'string') The mapping type to use for the column. -- ``column``: (optional, defaults to field name) The name of the +- ``name``: (optional, defaults to field name) The name of the column in the database. - ``length``: (optional, default 255) The length of the column in the database. (Applies only if a string-valued column is used).