123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602 |
- <?php
- namespace Doctrine\Tests\ORM\Query;
-
- use Doctrine\ORM\Query,
- Doctrine\ORM\Query\QueryException;
-
- require_once __DIR__ . '/../../TestInit.php';
-
- class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
- {
- private $_em;
-
- protected function setUp()
- {
- $this->_em = $this->_getTestEntityManager();
- }
-
- public function assertValidDQL($dql, $debug = false)
- {
- try {
- $parserResult = $this->parseDql($dql);
- } catch (QueryException $e) {
- if ($debug) {
- echo $e->getTraceAsString() . PHP_EOL;
- }
-
- $this->fail($e->getMessage());
- }
- }
-
- public function assertInvalidDQL($dql, $debug = false)
- {
- try {
- $parserResult = $this->parseDql($dql);
-
- $this->fail('No syntax errors were detected, when syntax errors were expected');
- } catch (QueryException $e) {
- if ($debug) {
- echo $e->getMessage() . PHP_EOL;
- echo $e->getTraceAsString() . PHP_EOL;
- }
- }
- }
-
- public function parseDql($dql, $hints = array())
- {
- $query = $this->_em->createQuery($dql);
- $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
- $query->setDql($dql);
-
- foreach ($hints as $key => $value) {
- $query->setHint($key, $value);
- }
-
- $parser = new \Doctrine\ORM\Query\Parser($query);
-
- // We do NOT test SQL output here. That only unnecessarily slows down the tests!
- $parser->setCustomOutputTreeWalker('Doctrine\Tests\Mocks\MockTreeWalker');
-
- return $parser->parse();
- }
-
- public function testEmptyQueryString()
- {
- $this->assertInvalidDQL('');
- }
-
- public function testPlainFromClauseWithAlias()
- {
- $this->assertValidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testSelectSingleComponentWithAsterisk()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testSelectSingleComponentWithMultipleColumns()
- {
- $this->assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testSelectMultipleComponentsUsingMultipleFrom()
- {
- $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user');
- }
-
- public function testSelectMultipleComponentsWithAsterisk()
- {
- $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
- }
-
- public function testSelectDistinctIsSupported()
- {
- $this->assertValidDQL('SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testAggregateFunctionInSelect()
- {
- $this->assertValidDQL('SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testDuplicatedAliasInAggregateFunction()
- {
- $this->assertInvalidDQL('SELECT COUNT(u.id) AS num, SUM(u.id) AS num FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testAggregateFunctionWithDistinctInSelect()
- {
- $this->assertValidDQL('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testFunctionalExpressionsSupportedInWherePart()
- {
- $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
- }
-
- public function testArithmeticExpressionsSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');
- }
-
- public function testInExpressionSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)');
- }
-
- public function testInExpressionWithoutSpacesSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1,2,3)');
- }
-
- public function testNotInExpressionSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)');
- }
-
- public function testInExpressionWithSingleValuedAssociationPathExpression()
- {
- $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)");
- }
-
- public function testInvalidInExpressionWithCollectionValuedAssociationPathExpression()
- {
- $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IN (?1, ?2)");
- }
-
- public function testInstanceOfExpressionSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee');
- }
-
- public function testInstanceOfExpressionWithInputParamSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1');
- }
-
- public function testNotInstanceOfExpressionSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u NOT INSTANCE OF ?1');
- }
-
- public function testExistsExpressionSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)');
- }
-
- public function testNotExistsExpressionSupportedInWherePart()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)');
- }
-
- public function testAggregateFunctionInHavingClause()
- {
- $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING COUNT(p.phonenumber) > 2');
- $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'romanb'");
- }
-
- public function testLeftJoin()
- {
- $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p');
- }
-
- public function testJoin()
- {
- $this->assertValidDQL('SELECT u,p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
- }
-
- public function testInnerJoin()
- {
- $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p');
- }
-
- public function testMultipleLeftJoin()
- {
- $this->assertValidDQL('SELECT u, a, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a LEFT JOIN u.phonenumbers p');
- }
-
- public function testMultipleInnerJoin()
- {
- $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INNER JOIN u.phonenumbers p');
- }
-
- public function testMixingOfJoins()
- {
- $this->assertValidDQL('SELECT u.name, a.topic, p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a LEFT JOIN u.phonenumbers p');
- }
-
- public function testOrderBySingleColumn()
- {
- $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name');
- }
-
- public function testOrderBySingleColumnAscending()
- {
- $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name ASC');
- }
-
- public function testOrderBySingleColumnDescending()
- {
- $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name DESC');
- }
-
- public function testOrderByMultipleColumns()
- {
- $this->assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username DESC, u.name DESC');
- }
-
- public function testSubselectInInExpression()
- {
- $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = 'zYne')");
- }
-
- public function testSubselectInSelectPart()
- {
- $this->assertValidDQL("SELECT u.name, (SELECT COUNT(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234) pcount FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
- }
-
- public function testArithmeticExpressionInSelectPart()
- {
- $this->assertValidDQL("SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u");
- }
-
- public function testArithmeticExpressionInSubselectPart()
- {
- $this->assertValidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
- }
-
- public function testArithmeticExpressionWithParenthesisInSubselectPart()
- {
- $this->assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
- }
-
- /**
- * @group DDC-1079
- */
- public function testSelectLiteralInSubselect()
- {
- $this->assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
- $this->assertValidDQL('SELECT (SELECT 0 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- /**
- * @group DDC-1077
- */
- public function testConstantValueInSelect()
- {
- $this->assertValidDQL("SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", true);
- }
-
- public function testDuplicateAliasInSubselectPart()
- {
- $this->assertInvalidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u2) foo FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'");
- }
-
- public function testPositionalInputParameter()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1');
- }
-
- public function testNamedInputParameter()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id');
- }
-
- public function testJoinConditionOverrideNotSupported()
- {
- $this->assertInvalidDQL("SELECT u.name, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'");
- }
-
- public function testIndexByClauseWithOneComponent()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id');
- }
-
- public function testIndexBySupportsJoins()
- {
- $this->assertValidDQL('SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a INDEX BY a.id'); // INDEX BY is now referring to articles
- }
-
- public function testIndexBySupportsJoins2()
- {
- $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p INDEX BY p.phonenumber');
- }
-
- public function testBetweenExpressionSupported()
- {
- $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name BETWEEN 'jepso' AND 'zYne'");
- }
-
- public function testNotBetweenExpressionSupported()
- {
- $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'");
- }
-
- public function testLikeExpression()
- {
- $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'");
- }
-
- public function testNotLikeExpression()
- {
- $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT LIKE 'z%'");
- }
-
- public function testLikeExpressionWithCustomEscapeCharacter()
- {
- $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'");
- }
-
- public function testFieldComparisonWithoutAlias()
- {
- $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE id = 1");
- }
-
- public function testDuplicatedAliasDeclaration()
- {
- $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles u WHERE u.id = 1");
- }
-
- public function testImplicitJoinInWhereOnSingleValuedAssociationPathExpression()
- {
- // This should be allowed because avatar is a single-value association.
- // SQL: SELECT ... FROM forum_user fu INNER JOIN forum_avatar fa ON fu.avatar_id = fa.id WHERE fa.id = ?
- $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a WHERE a.id = ?1");
- }
-
- public function testImplicitJoinInWhereOnCollectionValuedPathExpression()
- {
- // This should be forbidden, because articles is a collection
- $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a WHERE a.title = ?");
- }
-
- public function testInvalidSyntaxIsRejected()
- {
- $this->assertInvalidDQL("FOOBAR CmsUser");
- $this->assertInvalidDQL("DELETE FROM Doctrine\Tests\Models\CMS\CmsUser.articles");
- $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles.comments");
-
- // Currently UNDEFINED OFFSET error
- $this->assertInvalidDQL("SELECT c FROM CmsUser.articles.comments c");
- }
-
- public function testUpdateWorksWithOneField()
- {
- $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone'");
- }
-
- public function testUpdateWorksWithMultipleFields()
- {
- $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone', u.username = 'some'");
- }
-
- public function testUpdateSupportsConditions()
- {
- $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone' WHERE u.id = 5");
- }
-
- public function testDeleteAll()
- {
- $this->assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testDeleteWithCondition()
- {
- $this->assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = 3');
- }
-
- /**
- * The main use case for this generalized style of join is when a join condition
- * does not involve a foreign key relationship that is mapped to an entity relationship.
- */
- public function testImplicitJoinWithCartesianProductAndConditionInWhere()
- {
- $this->assertValidDQL("SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.name = a.topic");
- }
-
- public function testAllExpressionWithCorrelatedSubquery()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ALL (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
- }
-
- public function testCustomJoinsAndWithKeywordSupported()
- {
- $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p WITH p.phonenumber = 123 WHERE u.id = 1');
- }
-
- public function testAnyExpressionWithCorrelatedSubquery()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ANY (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
- }
-
- public function testSomeExpressionWithCorrelatedSubquery()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > SOME (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
- }
-
- public function testArithmeticExpressionWithoutParenthesisInWhereClause()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) + 1 > 10');
- }
-
- 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 'Joe' MEMBER OF u.nicknames");
- }
-
- public function testSizeFunction()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1');
- }
-
- public function testEmptyCollectionComparisonExpression()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY');
- }
-
- public function testSingleValuedAssociationFieldInWhere()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1');
- $this->assertValidDQL('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1');
- }
-
- public function testBooleanLiteralInWhere()
- {
- $this->assertValidDQL('SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true');
- }
-
- public function testSubqueryInSelectExpression()
- {
- $this->assertValidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testUsageOfQComponentOutsideSubquery()
- {
- $this->assertInvalidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u WHERE p.user = ?1');
- }
-
- public function testUnknownAbstractSchemaName()
- {
- $this->assertInvalidDQL('SELECT u FROM UnknownClassName u');
- }
-
- public function testCorrectPartialObjectLoad()
- {
- $this->assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testIncorrectPartialObjectLoadBecauseOfMissingIdentifier()
- {
- $this->assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testScalarExpressionInSelect()
- {
- $this->assertValidDQL('SELECT u, 42 + u.id AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- public function testInputParameterInSelect()
- {
- $this->assertValidDQL('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u');
- }
-
- /**
- * @group DDC-1091
- */
- public function testCustomFunctionsReturningStringInStringPrimary()
- {
- $this->_em->getConfiguration()->addCustomStringFunction('CC', 'Doctrine\ORM\Query\AST\Functions\ConcatFunction');
-
- $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'", true);
- }
-
- /**
- * @group DDC-505
- */
- public function testDQLKeywordInJoinIsAllowed()
- {
- $this->assertValidDQL('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g');
- }
-
- /**
- * @group DDC-505
- */
- public function testDQLKeywordInConditionIsAllowed()
- {
- $this->assertValidDQL('SELECT g FROM ' . __NAMESPACE__ . '\DQLKeywordsModelGroup g WHERE g.from=0');
- }
-
- /* The exception is currently thrown in the SQLWalker, not earlier.
- public function testInverseSideSingleValuedAssociationPathNotAllowed()
- {
- $this->assertInvalidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1');
- }
- */
-
- /**
- * @group DDC-617
- */
- public function testSelectOnlyNonRootEntityAlias()
- {
- $this->assertInvalidDQL('SELECT g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g');
- }
-
- /**
- * @group DDC-1108
- */
- public function testInputParameterSingleChar()
- {
- $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :q');
- }
-
- /**
- * @group DDC-1053
- */
- public function testGroupBy()
- {
- $this->assertValidDQL('SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id');
- }
-
- /**
- * @group DDC-1053
- */
- public function testGroupByIdentificationVariable()
- {
- $this->assertValidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g');
- }
-
- /**
- * @group DDC-1053
- */
- public function testGroupByUnknownIdentificationVariable()
- {
- $this->assertInvalidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY m');
- }
-
- /**
- * @group DDC-117
- */
- public function testSizeOfForeignKeyOneToManyPrimaryKeyEntity()
- {
- $this->assertValidDQL("SELECT a, t FROM Doctrine\Tests\Models\DDC117\DDC117Article a JOIN a.translations t WHERE SIZE(a.translations) > 0");
- }
-
- /**
- * @group DDC-117
- */
- public function testSizeOfForeignKeyManyToManyPrimaryKeyEntity()
- {
- $this->assertValidDQL("SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE SIZE(e.reviewingTranslations) > 0");
- }
-
- public function testCaseSupportContainingNullIfExpression()
- {
- $this->assertValidDQL("SELECT u.id, NULLIF(u.name, u.name) AS shouldBeNull FROM Doctrine\Tests\Models\CMS\CmsUser u");
- }
-
- public function testCaseSupportContainingCoalesceExpression()
- {
- $this->assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u");
- }
- }
-
- /** @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;
- /** @Column */
- private $from;
- }
|