BC break or bug? in ORM 2.5, select COUNT(entity) with relation as key #4994

Closed
opened 2026-01-22 14:56:02 +01:00 by admin · 1 comment
Owner

Originally created by @aurelijusrozenas on GitHub (Jan 27, 2016).

Works on 2.4.8, breaks in 2.5.0:

SELECT COUNT(dqltest) FROM AppBundle:DQLTest dqltest
[Semantical Error] line 0, col 13 near 'dqltest) FROM': Error: Invalid PathExpression. Must be a StateFieldPathExpression.

DQL works on both versions:

SELECT COUNT(dqltest.DQLTestParent) FROM AppBundle:DQLTest dqltest

I could not find any mentions about that in https://github.com/doctrine/doctrine2/blob/master/UPGRADE.md so I was wandering how to treat this in upgrade as a bug or as BC break?

class DQLTest
{
    /**
     * @var DQLTestParent
     *
     * @ORM\Id
     * @ORM\JoinColumn(referencedColumnName="id")
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\DQLTestParent")
     */
    private $DQLTestParent;
}
class DQLTestParent
{
    /**
     * @var int
     *
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
}
Originally created by @aurelijusrozenas on GitHub (Jan 27, 2016). Works on 2.4.8, breaks in 2.5.0: ``` SELECT COUNT(dqltest) FROM AppBundle:DQLTest dqltest ``` ``` [Semantical Error] line 0, col 13 near 'dqltest) FROM': Error: Invalid PathExpression. Must be a StateFieldPathExpression. ``` DQL works on both versions: ``` SELECT COUNT(dqltest.DQLTestParent) FROM AppBundle:DQLTest dqltest ``` I could not find any mentions about that in https://github.com/doctrine/doctrine2/blob/master/UPGRADE.md so I was wandering how to treat this in upgrade as a **bug** or as **BC break**? ``` class DQLTest { /** * @var DQLTestParent * * @ORM\Id * @ORM\JoinColumn(referencedColumnName="id") * @ORM\ManyToOne(targetEntity="AppBundle\Entity\DQLTestParent") */ private $DQLTestParent; } class DQLTestParent { /** * @var int * * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; } ```
admin added the BugMissing Tests labels 2026-01-22 14:56:02 +01:00
admin closed this issue 2026-01-22 14:56:02 +01:00
Author
Owner

@Ocramius commented on GitHub (Jan 27, 2016):

Does this only happen with this sort of association? Can you add an SQL generation test?

@Ocramius commented on GitHub (Jan 27, 2016): Does this only happen with this sort of association? Can you add an [SQL generation test](https://github.com/doctrine/doctrine2/blob/788143dc0313c7522820ebf6057f73881e7190a3/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php)?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4994