commit
a9bd51c0e4
@ -291,7 +291,8 @@ class SqlWalker implements TreeWalker
|
||||
$tableName .= ($dqlAlias) ? '@[' . $dqlAlias . ']' : '';
|
||||
|
||||
if ( ! isset($this->tableAliasMap[$tableName])) {
|
||||
$this->tableAliasMap[$tableName] = strtolower(substr($tableName, 0, 1)) . $this->tableAliasCounter++ . '_';
|
||||
$this->tableAliasMap[$tableName] = (preg_match('/[a-z]/i', $tableName[0]) ? strtolower($tableName[0]) : 't')
|
||||
. $this->tableAliasCounter++ . '_';
|
||||
}
|
||||
|
||||
return $this->tableAliasMap[$tableName];
|
||||
|
62
tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php
Normal file
62
tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Query;
|
||||
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\Tests\OrmTestCase;
|
||||
use Doctrine\ORM\Query\ParserResult;
|
||||
|
||||
/**
|
||||
* Tests for {@see \Doctrine\ORM\Query\SqlWalker}
|
||||
*
|
||||
* @covers \Doctrine\ORM\Query\SqlWalker
|
||||
*/
|
||||
class SqlWalkerTest extends OrmTestCase
|
||||
{
|
||||
/**
|
||||
* @var SqlWalker
|
||||
*/
|
||||
private $sqlWalker;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->sqlWalker = new SqlWalker(new Query($this->_getTestEntityManager()), new ParserResult(), array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getColumnNamesAndSqlAliases
|
||||
*/
|
||||
public function testGetSQLTableAlias($tableName, $expectedAlias)
|
||||
{
|
||||
$this->assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getColumnNamesAndSqlAliases
|
||||
*/
|
||||
public function testGetSQLTableAliasIsSameForMultipleCalls($tableName)
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->sqlWalker->getSQLTableAlias($tableName),
|
||||
$this->sqlWalker->getSQLTableAlias($tableName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private data provider
|
||||
*
|
||||
* @return string[][]
|
||||
*/
|
||||
public function getColumnNamesAndSqlAliases()
|
||||
{
|
||||
return array(
|
||||
array('aaaaa', 'a0_'),
|
||||
array('table', 't0_'),
|
||||
array('çtable', 't0_'),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user