DDC-2023: IDENTITY() in subquery throws error #2551

Closed
opened 2026-01-22 13:56:27 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 11, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user adrienbrault:

Hi, the following query

public function testIdentityFunctionInSubqueryClause()
{
    $sql = $this->_em->createQuery(
        "SELECT a
         FROM Doctrine\Tests\Models\CMS\CmsAddress a
         WHERE a.user IN (
             SELECT IDENTITY(a2.user)
             FROM Doctrine\Tests\Models\CMS\CmsArticle a2
         )"
    )->getSql();
}

throws an error:

1) Doctrine\Tests\ORM\Query\SelectSqlGenerationTest::testIdentityFunctionInSubqueryClause
Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 85: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '('

/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/QueryException.php:42
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:380
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:255
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:1189
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:1280
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2737
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2228
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2145
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2121
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2089
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2064
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:1212
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:760
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:727
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:213
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:288
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query.php:231
/Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query.php:177
/Users/adrienbrault/Developer/php/mygithub/doctrine2/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php:1375

I think that it's a bug and not a feature, because i tried to reproduce the last example from there http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#dql-select-examples

Originally created by @doctrinebot on GitHub (Sep 11, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user adrienbrault: Hi, the following query ``` public function testIdentityFunctionInSubqueryClause() { $sql = $this->_em->createQuery( "SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.user IN ( SELECT IDENTITY(a2.user) FROM Doctrine\Tests\Models\CMS\CmsArticle a2 )" )->getSql(); } ``` throws an error: ``` 1) Doctrine\Tests\ORM\Query\SelectSqlGenerationTest::testIdentityFunctionInSubqueryClause Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 85: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '(' /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/QueryException.php:42 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:380 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:255 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:1189 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:1280 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2737 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2228 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2145 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2121 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2089 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:2064 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:1212 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:760 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:727 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:213 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query/Parser.php:288 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query.php:231 /Users/adrienbrault/Developer/php/mygithub/doctrine2/lib/Doctrine/ORM/Query.php:177 /Users/adrienbrault/Developer/php/mygithub/doctrine2/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php:1375 ``` I think that it's a bug and not a feature, because i tried to reproduce the last example from there http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#dql-select-examples
admin added the Bug label 2026-01-22 13:56:27 +01:00
admin closed this issue 2026-01-22 13:56:27 +01:00
Author
Owner

@doctrinebot commented on GitHub (Sep 11, 2012):

Comment created by @asm89:

This is related to http://www.doctrine-project.org/jira/browse/DDC-1557. It seems the fix was not backported to 2.2.

@doctrinebot commented on GitHub (Sep 11, 2012): Comment created by @asm89: This is related to http://www.doctrine-project.org/jira/browse/[DDC-1557](http://www.doctrine-project.org/jira/browse/DDC-1557). It seems the fix was not backported to 2.2.
Author
Owner

@doctrinebot commented on GitHub (Jan 23, 2013):

Comment created by @ocramius:

[~adrienbrault] does it work for you in 2.3?

@doctrinebot commented on GitHub (Jan 23, 2013): Comment created by @ocramius: [~adrienbrault] does it work for you in 2.3?
Author
Owner

@doctrinebot commented on GitHub (Apr 14, 2013):

Comment created by @beberlei:

Duplicate of DDC-1557

@doctrinebot commented on GitHub (Apr 14, 2013): Comment created by @beberlei: Duplicate of [DDC-1557](http://www.doctrine-project.org/jira/browse/DDC-1557)
Author
Owner

@doctrinebot commented on GitHub (Apr 14, 2013):

Issue was closed with resolution "Duplicate"

@doctrinebot commented on GitHub (Apr 14, 2013): Issue was closed with resolution "Duplicate"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2551