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

Closed
doctrinebot opened this Issue Aug 2, 2011 · 7 comments

2 participants

@doctrinebot

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 )
}

@doctrinebot

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

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

Comment created by @guilhermeblanco:

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

@doctrinebot

Comment created by @beberlei:

Duplicate of DDC-2133 (better description)

@doctrinebot

Issue was closed with resolution "Duplicate"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 3.0 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment