DDC-3084: Native query removes duplicate root entities #3828

Open
opened 2026-01-22 14:28:44 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 14, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user sparrowek:

I have a query like that:

        $rsm = new ResultSetMappingBuilder($this->_em);
        $rsm->addScalarResult('rank', 'rank');
        $rsm->addRootEntityFromClassMetadata('Application\Entity', 'e');

        $query = $this->_em->createNativeQuery('
            SELECT
                r.rank, ' . $rsm->generateSelectClause(array('e')) . '
            FROM ...
        ', $rsm);

        return $query->getResult();

When I issue it at the mysql side it returns 3 rows but doctrine returns only 2 - I have tried getArrayResults() with the same results

The query could return the same entity multiple times for different values of the "rank" scalar value but it seems that doctrine removes those duplicates

Originally created by @doctrinebot on GitHub (Apr 14, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user sparrowek: I have a query like that: ``` $rsm = new ResultSetMappingBuilder($this->_em); $rsm->addScalarResult('rank', 'rank'); $rsm->addRootEntityFromClassMetadata('Application\Entity', 'e'); $query = $this->_em->createNativeQuery(' SELECT r.rank, ' . $rsm->generateSelectClause(array('e')) . ' FROM ... ', $rsm); return $query->getResult(); ``` When I issue it at the mysql side it returns 3 rows but doctrine returns only 2 - I have tried `getArrayResults()` with the same results The query could return the same entity multiple times for different values of the "rank" scalar value but it seems that doctrine removes those duplicates
admin added the Bug label 2026-01-22 14:28:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3828