DDC-1314: DQL permits partial select using SQL #1647

Closed
opened 2026-01-22 13:21:02 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (Aug 2, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user daniel.beresh:

The following code is not correct DQL and should (I think?) throw an error:

$query = $em->createQuery("SELECT g.id, g.name FROM Entity\Group g ORDER BY g.name ASC");

...to force the user to use SELECT partial g.{id,name} ...

Instead, it causes very funny behaviour. eg. when iterating, objects are passed to the foreach in the following pattern:

$groups = $query->iterate();
foreach(...) {
1st time: $groups = array( [0] => object )
2nd time: $groups = array( [1] => object )
3rd time: $groups = array( [2] => object )
}

Originally created by @doctrinebot on GitHub (Aug 2, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user daniel.beresh: The following code is not correct DQL and should (I think?) throw an error: ``` $query = $em->createQuery("SELECT g.id, g.name FROM Entity\Group g ORDER BY g.name ASC"); ``` ...to force the user to use SELECT partial g.{id,name} ... Instead, it causes very funny behaviour. eg. when iterating, objects are passed to the foreach in the following pattern: $groups = $query->iterate(); foreach(...) { 1st time: $groups = array( [0] => object ) 2nd time: $groups = array( [1] => object ) 3rd time: $groups = array( [2] => object ) }
admin added the Bug label 2026-01-22 13:21:02 +01:00
admin closed this issue 2026-01-22 13:21:04 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 2, 2011):

@doctrinebot commented on GitHub (Aug 2, 2011): - duplicates [DDC-2133: Issue with Query::iterate and query mixed results](http://www.doctrine-project.org/jira/browse/DDC-2133)
Author
Owner

@doctrinebot commented on GitHub (Aug 6, 2011):

Comment created by @beberlei:

The incrementation of the return value is a bug, but SELECT g.id, g.name is valid DQL. You hydrate the values as scalars. What is funny is why it even returns an object in this case.

@doctrinebot commented on GitHub (Aug 6, 2011): Comment created by @beberlei: The incrementation of the return value is a bug, but SELECT g.id, g.name is valid DQL. You hydrate the values as scalars. What is funny is why it even returns an object in this case.
Author
Owner

@doctrinebot commented on GitHub (Dec 11, 2011):

Comment created by @guilhermeblanco:

Added failing test case.
Currently it is not easily doable without larger refactoring of Hydrators.
I'll keep this opened, but my 2 attempts failed.

@doctrinebot commented on GitHub (Dec 11, 2011): Comment created by @guilhermeblanco: Added failing test case. Currently it is not easily doable without larger refactoring of Hydrators. I'll keep this opened, but my 2 attempts failed.
Author
Owner

@doctrinebot commented on GitHub (Jun 23, 2012):

Comment created by @guilhermeblanco:

Scheduled for 3.0 since we're going to refactor the hydrators

@doctrinebot commented on GitHub (Jun 23, 2012): Comment created by @guilhermeblanco: Scheduled for 3.0 since we're going to refactor the hydrators
Author
Owner

@doctrinebot commented on GitHub (May 1, 2013):

Comment created by @beberlei:

Duplicate of DDC-2133 (better description)

@doctrinebot commented on GitHub (May 1, 2013): Comment created by @beberlei: Duplicate of [DDC-2133](http://www.doctrine-project.org/jira/browse/DDC-2133) (better description)
Author
Owner

@doctrinebot commented on GitHub (May 1, 2013):

Issue was closed with resolution "Duplicate"

@doctrinebot commented on GitHub (May 1, 2013): Issue was closed with resolution "Duplicate"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/5149a842b5d604b04b1b

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/5149a842b5d604b04b1b - [11128_IteratableHydratorTest.php](https://gist.github.com/5149a842b5d604b04b1b#file-11128_IteratableHydratorTest-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1647