DDC-1385: INDEX BY doesn't work for selects with scalars only #1733

Closed
opened 2026-01-22 13:23:37 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 21, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user strygin:

By scalars-only-selects I mean this:

SELECT c.id, c.name FROM GLocalityBundle:Country c  INDEX by c.id 

The result won't be indexed by c.id, as opposites to this:

SELECT c FROM GLocalityBundle:Country c  INDEX by c.id 

Assuming that GLocalityBundle:Country has several hunders of fields, and you need only two of them, this is very disappointing :(

After diving in the code, due to rigorous separation of entities on objects and scalars, it looks practically impossible even to implement this feature :(
What is this? Bad design?

Originally created by @doctrinebot on GitHub (Sep 21, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user strygin: By scalars-only-selects I mean this: ``` SELECT c.id, c.name FROM GLocalityBundle:Country c INDEX by c.id ``` The result won't be indexed by _c.id_, as opposites to this: ``` SELECT c FROM GLocalityBundle:Country c INDEX by c.id ``` Assuming that GLocalityBundle:Country has several hunders of fields, and you need only two of them, this is very disappointing :( After diving in the code, due to rigorous separation of entities on objects and scalars, it looks practically impossible even to implement this feature :( What is this? Bad design?
admin added the Bug label 2026-01-22 13:23:37 +01:00
admin closed this issue 2026-01-22 13:23:38 +01:00
Author
Owner

@doctrinebot commented on GitHub (Sep 25, 2011):

Comment created by @beberlei:

I agree it seems very complex to implement for the Object and ArrayHydrator, however it should be very easy for the getScalarResult() hydrator.

Even more I think there is a general bug with INDEX BY and scalars in Object and ArrayHydrator that has to be evaluated.

@doctrinebot commented on GitHub (Sep 25, 2011): Comment created by @beberlei: I agree it seems very complex to implement for the Object and ArrayHydrator, however it should be very easy for the getScalarResult() hydrator. Even more I think there is a general bug with INDEX BY and scalars in Object and ArrayHydrator that has to be evaluated.
Author
Owner

@doctrinebot commented on GitHub (Oct 31, 2011):

Comment created by @beberlei:

This PR will fix this issue https://github.com/doctrine/doctrine2/pull/151, it is scheduled for 2.2

@doctrinebot commented on GitHub (Oct 31, 2011): Comment created by @beberlei: This PR will fix this issue https://github.com/doctrine/doctrine2/pull/151, it is scheduled for 2.2
Author
Owner

@doctrinebot commented on GitHub (Nov 8, 2011):

Comment created by @beberlei:

This is fixed in master

@doctrinebot commented on GitHub (Nov 8, 2011): Comment created by @beberlei: This is fixed in master
Author
Owner

@doctrinebot commented on GitHub (Nov 8, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Nov 8, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Apr 1, 2012):

Comment created by deatheriam:

This behavior has not changed in the latest 2.2.1. getArrayResult returns an indexed result. getScalarResult returns zero based result. Do I need to create a separate ticket for that issue?

@doctrinebot commented on GitHub (Apr 1, 2012): Comment created by deatheriam: This behavior has not changed in the latest 2.2.1. getArrayResult returns an indexed result. getScalarResult returns zero based result. Do I need to create a separate ticket for that issue?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1733