[2.0][DDC-234] Make sure is defined in QueryBuilder Expressions.
This commit is contained in:
parent
ae4f823f26
commit
0a7727e16a
@ -93,10 +93,10 @@ class Expr
|
||||
* $q->from($q->expr()->from('User', 'u'));
|
||||
*
|
||||
* @param string $from Entity name.
|
||||
* @param string $alias Optional alias to be used by Entity.
|
||||
* @param string $alias Alias to be used by Entity.
|
||||
* @return Expr\From
|
||||
*/
|
||||
public function from($from, $alias = null)
|
||||
public function from($from, $alias)
|
||||
{
|
||||
return new Expr\From($from, $alias);
|
||||
}
|
||||
@ -109,13 +109,13 @@ class Expr
|
||||
* $q->expr()->leftJoin('u.Group', 'g', 'WITH', "g.name = 'admin'")
|
||||
*
|
||||
* @param string $join Relation join.
|
||||
* @param string $alias Optional alias to be used by Relation.
|
||||
* @param string $alias Alias to be used by Relation.
|
||||
* @param string $conditionType Optional type of condition appender. Accepts either string or constant.
|
||||
* 'ON' and 'WITH' are supported strings. Expr\Join::ON and Expr\Join::WITH are supported constants.
|
||||
* @param mixed $condition Optional condition to be appended.
|
||||
* @return Expr\Join
|
||||
*/
|
||||
public function leftJoin($join, $alias = null, $conditionType = null, $condition = null)
|
||||
public function leftJoin($join, $alias, $conditionType = null, $condition = null)
|
||||
{
|
||||
return new Expr\Join(Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition);
|
||||
}
|
||||
@ -128,13 +128,13 @@ class Expr
|
||||
* $q->expr()->innerJoin('u.Group', 'g', 'WITH', "g.name = 'admin'")
|
||||
*
|
||||
* @param string $join Relation join.
|
||||
* @param string $alias Optional alias to be used by Relation.
|
||||
* @param string $alias Alias to be used by Relation.
|
||||
* @param string $conditionType Optional type of condition appender. Accepts either string or constant.
|
||||
* 'ON' and 'WITH' are supported strings. Expr\Join::ON and Expr\Join::WITH are supported constants.
|
||||
* @param mixed $condition Optional condition to be appended.
|
||||
* @return Expr\Join
|
||||
*/
|
||||
public function innerJoin($join, $alias = null, $conditionType = null, $condition = null)
|
||||
public function innerJoin($join, $alias, $conditionType = null, $condition = null)
|
||||
{
|
||||
return new Expr\Join(Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class From
|
||||
private $_from;
|
||||
private $_alias;
|
||||
|
||||
public function __construct($from, $alias = null)
|
||||
public function __construct($from, $alias)
|
||||
{
|
||||
$this->_from = $from;
|
||||
$this->_alias = $alias;
|
||||
@ -55,6 +55,6 @@ class From
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->_from . ($this->_alias ? ' ' . $this->_alias : '');
|
||||
return $this->_from . ' ' . $this->_alias;
|
||||
}
|
||||
}
|
@ -495,7 +495,7 @@ class QueryBuilder
|
||||
* @param string $alias The alias of the model
|
||||
* @return QueryBuilder $qb
|
||||
*/
|
||||
public function from($from, $alias = null)
|
||||
public function from($from, $alias)
|
||||
{
|
||||
return $this->add('from', new Expr\From($from, $alias), true);
|
||||
}
|
||||
@ -515,7 +515,7 @@ class QueryBuilder
|
||||
* @param string $condition The condition for the join
|
||||
* @return QueryBuilder $qb
|
||||
*/
|
||||
public function innerJoin($join, $alias = null, $conditionType = null, $condition = null)
|
||||
public function innerJoin($join, $alias, $conditionType = null, $condition = null)
|
||||
{
|
||||
return $this->add('join', new Expr\Join(
|
||||
Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition
|
||||
@ -537,7 +537,7 @@ class QueryBuilder
|
||||
* @param string $condition The condition for the join
|
||||
* @return QueryBuilder $qb
|
||||
*/
|
||||
public function leftJoin($join, $alias = null, $conditionType = null, $condition = null)
|
||||
public function leftJoin($join, $alias, $conditionType = null, $condition = null)
|
||||
{
|
||||
return $this->add('join', new Expr\Join(
|
||||
Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition
|
||||
|
@ -71,6 +71,20 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
|
||||
{
|
||||
$this->assertType('\Doctrine\ORM\QueryBuilder', $this->_em->createQueryBuilder());
|
||||
}
|
||||
|
||||
public function testCreateQueryBuilderAliasValid()
|
||||
{
|
||||
$q = $this->_em->createQueryBuilder()
|
||||
->select('u')->from('Doctrine\Tests\Models\CMS\CmsUser', 'u');
|
||||
$q2 = clone $q;
|
||||
|
||||
$this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q->getQuery()->getDql());
|
||||
$this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q2->getQuery()->getDql());
|
||||
|
||||
$q3 = clone $q;
|
||||
|
||||
$this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q3->getQuery()->getDql());
|
||||
}
|
||||
|
||||
public function testCreateQuery_DqlIsOptional()
|
||||
{
|
||||
|
@ -278,7 +278,6 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
public function testFromExpr()
|
||||
{
|
||||
$this->assertEquals('User', (string) $this->_expr->from('User'));
|
||||
$this->assertEquals('User u', (string) $this->_expr->from('User', 'u'));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user