From 442f040d861befc85be3a694851e4644c77cec06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ch=C3=A1bek?= Date: Fri, 9 Aug 2013 20:38:34 +0200 Subject: [PATCH] DqlSelection: fixed automatic aliasing --- src/Kdyby/Doctrine/EntityDao.php | 3 ++- tests/KdybyTests/Doctrine/EntityDao.phpt | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Kdyby/Doctrine/EntityDao.php b/src/Kdyby/Doctrine/EntityDao.php index aacb94ca..d4ead157 100644 --- a/src/Kdyby/Doctrine/EntityDao.php +++ b/src/Kdyby/Doctrine/EntityDao.php @@ -215,7 +215,8 @@ public function findAssoc($criteria, $key = NULL) public function select($alias = NULL, $indexBy = NULL) { if ($alias === NULL) { - $alias = strtolower(substr($this->_entityName, strrpos($this->_entityName, '\\'), 1)); + $pos = strrpos($this->_entityName, '\\'); + $alias = strtolower(substr($this->_entityName, $pos === FALSE ? 0 : $pos + 1, 1)); } $selection = $this->getEntityManager()->createSelection(); diff --git a/tests/KdybyTests/Doctrine/EntityDao.phpt b/tests/KdybyTests/Doctrine/EntityDao.phpt index 36ac8f68..58708ed3 100644 --- a/tests/KdybyTests/Doctrine/EntityDao.phpt +++ b/tests/KdybyTests/Doctrine/EntityDao.phpt @@ -105,6 +105,16 @@ class EntityDaoTest extends ORMTestCase Assert::same('SELECT u FROM KdybyTests\Doctrine\CmsUser u INDEX BY u.id', $qb->getDQL()); } + + + public function testSelectWithoutParameters() + { + $users = $this->em->getDao('KdybyTests\Doctrine\CmsUser'); + $qb = $users->select(); + + Assert::same('SELECT c FROM KdybyTests\Doctrine\CmsUser c', $qb->getDQL()); + } + } \run(new EntityDaoTest());