[2.0][DDC-339][DDC-340] Fixed.
This commit is contained in:
parent
ec880fe555
commit
22fce635c0
@ -159,7 +159,7 @@ class ClassMetadata extends ClassMetadataInfo
|
|||||||
* with the same order as the field order in {@link identifier}.
|
* with the same order as the field order in {@link identifier}.
|
||||||
*
|
*
|
||||||
* @param object $entity
|
* @param object $entity
|
||||||
* @return mixed
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getIdentifierValues($entity)
|
public function getIdentifierValues($entity)
|
||||||
{
|
{
|
||||||
|
@ -220,8 +220,9 @@ final class Query extends AbstractQuery
|
|||||||
|
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
$values = $this->_em->getClassMetadata(get_class($value))->getIdentifierValues($value);
|
$values = $this->_em->getClassMetadata(get_class($value))->getIdentifierValues($value);
|
||||||
|
//var_dump($this->_em->getUnitOfWork()->getEntityIdentifier($value));
|
||||||
$sqlPositions = $paramMappings[$key];
|
$sqlPositions = $paramMappings[$key];
|
||||||
$sqlParams = array_merge($sqlParams, array_combine((array)$sqlPositions, (array)$values));
|
$sqlParams = array_merge($sqlParams, array_combine((array)$sqlPositions, $values));
|
||||||
} else if (is_bool($value)) {
|
} else if (is_bool($value)) {
|
||||||
$boolValue = $this->_em->getConnection()->getDatabasePlatform()->convertBooleans($value);
|
$boolValue = $this->_em->getConnection()->getDatabasePlatform()->convertBooleans($value);
|
||||||
foreach ($paramMappings[$key] as $position) {
|
foreach ($paramMappings[$key] as $position) {
|
||||||
|
@ -929,8 +929,7 @@ class Parser
|
|||||||
|
|
||||||
$identVariable = $this->IdentificationVariable();
|
$identVariable = $this->IdentificationVariable();
|
||||||
$this->match(Lexer::T_DOT);
|
$this->match(Lexer::T_DOT);
|
||||||
//TODO: $this->match($this->_lexer->lookahead['value']);
|
$this->match($this->_lexer->lookahead['type']);
|
||||||
$this->match(Lexer::T_IDENTIFIER);
|
|
||||||
$field = $this->_lexer->token['value'];
|
$field = $this->_lexer->token['value'];
|
||||||
|
|
||||||
// Validate association field
|
// Validate association field
|
||||||
@ -1878,17 +1877,7 @@ class Parser
|
|||||||
|
|
||||||
if ($this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
|
if ($this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
|
||||||
// Peek beyond the matching closing paranthesis ')'
|
// Peek beyond the matching closing paranthesis ')'
|
||||||
$numUnmatched = 1;
|
$peek = $this->_peekBeyondClosingParenthesis();
|
||||||
$peek = $this->_lexer->peek();
|
|
||||||
while ($numUnmatched > 0 && $peek !== null) {
|
|
||||||
if ($peek['value'] == ')') {
|
|
||||||
--$numUnmatched;
|
|
||||||
} else if ($peek['value'] == '(') {
|
|
||||||
++$numUnmatched;
|
|
||||||
}
|
|
||||||
$peek = $this->_lexer->peek();
|
|
||||||
}
|
|
||||||
$this->_lexer->resetPeek();
|
|
||||||
|
|
||||||
if (in_array($peek['value'], array("=", "<", "<=", "<>", ">", ">=", "!=")) ||
|
if (in_array($peek['value'], array("=", "<", "<=", "<>", ">", ">=", "!=")) ||
|
||||||
$peek['type'] === Lexer::T_NOT ||
|
$peek['type'] === Lexer::T_NOT ||
|
||||||
@ -1928,11 +1917,15 @@ class Parser
|
|||||||
return $this->ExistsExpression();
|
return $this->ExistsExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
$pathExprOrInputParam = false;
|
$peek = $this->_lexer->glimpse();
|
||||||
|
|
||||||
if ($token['type'] === Lexer::T_IDENTIFIER || $token['type'] === Lexer::T_INPUT_PARAMETER) {
|
if ($token['type'] === Lexer::T_IDENTIFIER || $token['type'] === Lexer::T_INPUT_PARAMETER) {
|
||||||
// Peek beyond the PathExpression
|
if ($peek['value'] == '(') {
|
||||||
$pathExprOrInputParam = true;
|
// Peek beyond the matching closing paranthesis ')'
|
||||||
|
$this->_lexer->peek();
|
||||||
|
$token = $this->_peekBeyondClosingParenthesis();
|
||||||
|
} else {
|
||||||
|
// Peek beyond the PathExpression (or InputParameter)
|
||||||
$peek = $this->_lexer->peek();
|
$peek = $this->_lexer->peek();
|
||||||
|
|
||||||
while ($peek['value'] === '.') {
|
while ($peek['value'] === '.') {
|
||||||
@ -1957,41 +1950,42 @@ class Parser
|
|||||||
|
|
||||||
$this->_lexer->resetPeek();
|
$this->_lexer->resetPeek();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($pathExprOrInputParam) {
|
|
||||||
switch ($token['type']) {
|
switch ($token['type']) {
|
||||||
case Lexer::T_EQUALS:
|
|
||||||
case Lexer::T_LOWER_THAN:
|
|
||||||
case Lexer::T_GREATER_THAN:
|
|
||||||
case Lexer::T_NEGATE:
|
|
||||||
case Lexer::T_OPEN_PARENTHESIS:
|
|
||||||
return $this->ComparisonExpression();
|
|
||||||
|
|
||||||
case Lexer::T_BETWEEN:
|
case Lexer::T_BETWEEN:
|
||||||
return $this->BetweenExpression();
|
return $this->BetweenExpression();
|
||||||
|
|
||||||
case Lexer::T_LIKE:
|
case Lexer::T_LIKE:
|
||||||
return $this->LikeExpression();
|
return $this->LikeExpression();
|
||||||
|
|
||||||
case Lexer::T_IN:
|
case Lexer::T_IN:
|
||||||
return $this->InExpression();
|
return $this->InExpression();
|
||||||
|
|
||||||
case Lexer::T_IS:
|
case Lexer::T_IS:
|
||||||
if ($lookahead['type'] == Lexer::T_NULL) {
|
if ($lookahead['type'] == Lexer::T_NULL) {
|
||||||
return $this->NullComparisonExpression();
|
return $this->NullComparisonExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->EmptyCollectionComparisonExpression();
|
return $this->EmptyCollectionComparisonExpression();
|
||||||
|
|
||||||
case Lexer::T_MEMBER:
|
case Lexer::T_MEMBER:
|
||||||
return $this->CollectionMemberExpression();
|
return $this->CollectionMemberExpression();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$this->syntaxError();
|
return $this->ComparisonExpression();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->ComparisonExpression();
|
private function _peekBeyondClosingParenthesis()
|
||||||
|
{
|
||||||
|
$numUnmatched = 1;
|
||||||
|
$token = $this->_lexer->peek();
|
||||||
|
while ($numUnmatched > 0 && $token !== null) {
|
||||||
|
if ($token['value'] == ')') {
|
||||||
|
--$numUnmatched;
|
||||||
|
} else if ($token['value'] == '(') {
|
||||||
|
++$numUnmatched;
|
||||||
|
}
|
||||||
|
$token = $this->_lexer->peek();
|
||||||
|
}
|
||||||
|
$this->_lexer->resetPeek();
|
||||||
|
|
||||||
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,7 +442,7 @@ class SqlWalker implements TreeWalker
|
|||||||
throw QueryException::associationPathCompositeKeyNotSupported();
|
throw QueryException::associationPathCompositeKeyNotSupported();
|
||||||
}
|
}
|
||||||
$sql .= $this->walkIdentificationVariable($dqlAlias) . '.'
|
$sql .= $this->walkIdentificationVariable($dqlAlias) . '.'
|
||||||
. $assoc->getQuotedJoinColumnName(key($assoc->sourceToTargetKeyColumns), $this->_platform);
|
. $assoc->getQuotedJoinColumnName(reset($assoc->targetToSourceKeyColumns), $this->_platform);
|
||||||
} else {
|
} else {
|
||||||
// 2- Inverse side: NOT (YET?) SUPPORTED
|
// 2- Inverse side: NOT (YET?) SUPPORTED
|
||||||
throw QueryException::associationPathInverseSideNotSupported();
|
throw QueryException::associationPathInverseSideNotSupported();
|
||||||
|
@ -547,7 +547,6 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
|
|
||||||
public function testFlushDoesNotIssueUnnecessaryUpdates()
|
public function testFlushDoesNotIssueUnnecessaryUpdates()
|
||||||
{
|
{
|
||||||
|
|
||||||
$user = new CmsUser;
|
$user = new CmsUser;
|
||||||
$user->name = 'Guilherme';
|
$user->name = 'Guilherme';
|
||||||
$user->username = 'gblanco';
|
$user->username = 'gblanco';
|
||||||
@ -613,6 +612,35 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
//$this->_em->getConnection()->getConfiguration()->setSqlLogger(null);
|
//$this->_em->getConnection()->getConfiguration()->setSqlLogger(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group ref
|
||||||
|
*/
|
||||||
|
/*public function testQueryEntityByReference()
|
||||||
|
{
|
||||||
|
$user = new CmsUser;
|
||||||
|
$user->name = 'Guilherme';
|
||||||
|
$user->username = 'gblanco';
|
||||||
|
$user->status = 'developer';
|
||||||
|
|
||||||
|
$address = new CmsAddress;
|
||||||
|
$address->country = 'Germany';
|
||||||
|
$address->city = 'Berlin';
|
||||||
|
$address->zip = '12345';
|
||||||
|
|
||||||
|
$user->setAddress($address);
|
||||||
|
|
||||||
|
$this->_em->persist($user);
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$userRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->getId());
|
||||||
|
$address2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsAddress a where a.user = :user')
|
||||||
|
->setParameter('user', $userRef)
|
||||||
|
->getSingleResult();
|
||||||
|
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
//DRAFT OF EXPECTED/DESIRED BEHAVIOR
|
//DRAFT OF EXPECTED/DESIRED BEHAVIOR
|
||||||
/*public function testPersistentCollectionContainsDoesNeverInitialize()
|
/*public function testPersistentCollectionContainsDoesNeverInitialize()
|
||||||
{
|
{
|
||||||
|
@ -350,6 +350,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
public function testMemberOfExpression()
|
public function testMemberOfExpression()
|
||||||
{
|
{
|
||||||
$this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers');
|
$this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers');
|
||||||
|
//$this->assertValidDql("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE 'Joe' MEMBER OF u.nicknames");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSizeFunction()
|
public function testSizeFunction()
|
||||||
@ -408,6 +409,11 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertValidDql('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
|
$this->assertValidDql('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDQLKeywordInJoinIsAllowed()
|
||||||
|
{
|
||||||
|
$this->assertValidDql('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g');
|
||||||
|
}
|
||||||
|
|
||||||
/* The exception is currently thrown in the SQLWalker, not earlier.
|
/* The exception is currently thrown in the SQLWalker, not earlier.
|
||||||
public function testInverseSideSingleValuedAssociationPathNotAllowed()
|
public function testInverseSideSingleValuedAssociationPathNotAllowed()
|
||||||
{
|
{
|
||||||
@ -415,3 +421,19 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @Entity */
|
||||||
|
class DQLKeywordsModelUser
|
||||||
|
{
|
||||||
|
/** @Id @Column(type="integer") @GeneratedValue */
|
||||||
|
private $id;
|
||||||
|
/** @OneToOne(targetEntity="DQLKeywordsModelGroup") */
|
||||||
|
private $group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @Entity */
|
||||||
|
class DQLKeywordsModelGroup
|
||||||
|
{
|
||||||
|
/** @Id @Column(type="integer") @GeneratedValue */
|
||||||
|
private $id;
|
||||||
|
}
|
||||||
|
@ -483,7 +483,6 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testBooleanLiteralInWhereOnSqlite()
|
public function testBooleanLiteralInWhereOnSqlite()
|
||||||
{
|
{
|
||||||
$oldPlat = $this->_em->getConnection()->getDatabasePlatform();
|
$oldPlat = $this->_em->getConnection()->getDatabasePlatform();
|
||||||
@ -520,22 +519,14 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->_em->getConnection()->setDatabasePlatform($oldPlat);
|
$this->_em->getConnection()->setDatabasePlatform($oldPlat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Not yet implemented, needs more thought */
|
|
||||||
public function testSingleValuedAssociationFieldInWhere()
|
public function testSingleValuedAssociationFieldInWhere()
|
||||||
{
|
{
|
||||||
/*$this->assertSqlGeneration(
|
|
||||||
"SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1",
|
|
||||||
"SELECT c0_.id AS id0, c0_user_id AS user_id1, c0_.phonenumber AS phonenumber2 FROM cms_phonenumbers c0_ WHERE c0_.user_id = ?"
|
|
||||||
);
|
|
||||||
$this->assertSqlGeneration(
|
$this->assertSqlGeneration(
|
||||||
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1",
|
"SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1",
|
||||||
//"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.id = (SELECT c1_.user_id FROM cms_addresses c1_ WHERE c1_.id = ?)"
|
"SELECT c0_.phonenumber AS phonenumber0 FROM cms_phonenumbers c0_ WHERE c0_.user_id = ?"
|
||||||
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_addresses c1_ WHERE c1_.user_id = c0_.id AND c1_.id = ?)"
|
);
|
||||||
);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testSingleValuedAssociationNullCheckOnOwningSide()
|
public function testSingleValuedAssociationNullCheckOnOwningSide()
|
||||||
{
|
{
|
||||||
$this->assertSqlGeneration(
|
$this->assertSqlGeneration(
|
||||||
@ -554,4 +545,23 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL"
|
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-339
|
||||||
|
*/
|
||||||
|
public function testStringFunctionLikeExpression()
|
||||||
|
{
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) LIKE '%foo OR bar%'",
|
||||||
|
"SELECT c0_.name AS name0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE '%foo OR bar%'"
|
||||||
|
);
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) LIKE :str",
|
||||||
|
"SELECT c0_.name AS name0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE ?"
|
||||||
|
);
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(UPPER(u.name), '_moo') LIKE :str",
|
||||||
|
"SELECT c0_.name AS name0 FROM cms_users c0_ WHERE UPPER(c0_.name) || '_moo' LIKE ?"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user