After updating from 2.5.3 to 2.6.0 the following query is not longer working:
SELECT Sulu\\Bundle\\Entity\\Category.id FROM Sulu\\Bundle\\Entity\\Category Sulu\\Bundle\\Entity\\Category
also not longer working:
SELECT SuluBundleCategory:Category.id FROM SuluBundleCategory:Category SuluBundleCategory:Category
It produce by use case different errors for joins, select or froms:
Expected Doctrine\\ORM\\Query\\Lexer::T_IDENTIFIER, got ...
or
Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | \"(\" Subselect \")\" | CaseExpression, got ...
Hmm, aliases were always supposed to be alnum only: never seen such an
example before.
Investigating ASAP
On 20 Dec 2017 17:42, "L91" notifications@github.com wrote:
After updating from 2.5.3 to 2.6.0 the following query is not longer
working:SELECT Sulu\Bundle\Entity\Category.id FROM Sulu\Bundle\Entity\Category Sulu\Bundle\Entity\Category
also not longer working:
SELECT SuluBundleCategory:Category.id FROM SuluBundleCategory:Category SuluBundleCategory:Category
It produce by use case different errors for joins, select or froms:
Expected Doctrine\ORM\Query\Lexer::T_IDENTIFIER, got ...
or
Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | \"(\" Subselect \")\" | CaseExpression, got
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6928, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakLMpvhcpYxMi6qfZr1P7zMOqPL_8ks5tCTjxgaJpZM4RIqJV
.
Possibly related change: b7bd42638dcf8aa049698f01466688ff7762953b, will try to bisect later if @Ocramius isn't faster.
@Majkl578 adding a test case ATM
https://github.com/doctrine/doctrine2/pull/1549#issuecomment-173212939 - hah.
Yeah, this is invalid DQL as per https://github.com/doctrine/doctrine2/blob/b7bd42638dcf8aa049698f01466688ff7762953b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php#L98-L99
I think this is an edge case and we shouldn't go back on it - the original fix is more relevant, so I'm more inclined to documenting it as known BC break.
I think this is an edge case and we shouldn't go back on it - the original fix is more relevant, so I'm more inclined to documenting it as known BC break.
Ok thought that 🙈 . But thank you for investing time to analyse the issue. As its currently for us not possible to fix this without to many BC Breaks in our CMS we need to go back to 2.5.
Hmm, aliases were always supposed to be alnum only: never seen such an
example before.
The queries are built by a service this way in our CMS but also the devs can input condition like SuluBundleCategory:Category.locale = "en:uk" to this service and it seems many projects did it this way and they are now breaking and a str_replace([':', '\\'], '', $query) which I tried in our case I think is to error-prone as also the comparetivy value ("en:uk") content could be replaced by this str_replace.
Bisect done, caused by the commit already mentioned: b7bd42638dcf8aa049698f01466688ff7762953b, likely to be broken by change to cachable patterns: https://github.com/doctrine/doctrine2/commit/b7bd42638dcf8aa049698f01466688ff7762953b#diff-a59574e15d37179f26dc0056f2a6d4b0R131
@aleeeftw these are the scenarios. First two pass, second two crash as per @Majkl578's findings
/**
* @group #6928
*/
public function testStringParameterWithNamespaceSeparator()
{
$this->assertSqlGeneration(
\sprintf('SELECT a FROM %s a WHERE a.username=\'en\\uk\'', CmsUser::class),
'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.username = \'en\\uk\''
);
}
/**
* @group #6928
*/
public function testStringParameterWithNamespaceAliasSeparator()
{
$this->assertSqlGeneration(
\sprintf('SELECT a FROM %s a WHERE a.username=\'en:uk\'', CmsUser::class),
'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.username = \'en:uk\''
);
}
/**
* @group #6928
*/
public function testClassNameWithNamespaceIsAValidAlias()
{
$this->assertSqlGeneration(
\sprintf('SELECT %s FROM %s %s', CmsUser::class, CmsUser::class, CmsUser::class),
''
);
}
/**
* @group #6928
*/
public function testAliasedClassNameIsAValidAlias()
{
$originalNamespaces = $this->_em->getConfiguration()->getEntityNamespaces();
$this->_em->getConfiguration()->setEntityNamespaces([
'Potato' => 'Doctrine\\Tests\\Models\\CMS',
]);
try {
$this->assertSqlGeneration(
'SELECT Potato:CmsUser FROM Potato:CmsUser Potato:CmsUser',
''
);
} finally {
$this->_em->getConfiguration()->setEntityNamespaces($originalNamespaces);
}
}
@Ocramius Hi, I think you tagged me by mistake in this issue? :) Not sure how I broke that?!
Sorry, auto-complete SNAFU
@Ocramius As I think this behaviour will not be change to allow aliases something else then AlphaNum value the issue can be closed and labeled as will not be fixed. If you want to let it open feel to reopen it.