Skip to content

Commit

Permalink
DqlSelection: fixed automatic aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
grongor authored and fprochazka committed Aug 9, 2013
1 parent b62876b commit 442f040
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Kdyby/Doctrine/EntityDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions tests/KdybyTests/Doctrine/EntityDao.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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());

0 comments on commit 442f040

Please sign in to comment.