DDC-3367: [GH-1171] Improvements for complex select statements when using new object expression #4159

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

Originally created by @doctrinebot on GitHub (Oct 28, 2014).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of jaimz22:

Url: https://github.com/doctrine/doctrine2/pull/1171

Message:

My update allows you to alias objects created with the "new" object expression, as well as the ability to create queries that allow you to have multiple "new" object expressions and mixed scalar results.

Suppose you create a query as such:

SELECT new UserDTO(u.id,u.name) as user,new AddressDTO(a.street,a.postalCode) as address, a.id as addressId FROM User u INNER JOIN u.addresses a WITH a.isPrimary = true

upon executing this query, you'll end up with a result set that looks like the following:

array(
    0=>array(
        0=>{UserDTO object},
        1=>{AddressDTO object},
        2=>{u.id scalar},
        3=>{u.name scalar},
        4=>{a.street scalar},
        5=>{a.postalCode scalar},
        'addressId'=>{a.id scalar},
    ),
    ...
)

My changes fix that so you'd end up with a more usable result set:

array(
    0=>array(
        'user'=>{UserDTO object},
        'address'=>{AddressDTO object},
        'addressId'=>{a.id scalar}
    )
    ...
)
Originally created by @doctrinebot on GitHub (Oct 28, 2014). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of jaimz22: Url: https://github.com/doctrine/doctrine2/pull/1171 Message: My update allows you to alias objects created with the ["new" object expression](http://doctrine-orm.readthedocs.org/en/latest/reference/dql-doctrine-query-language.html#new-operator-syntax), as well as the ability to create queries that allow you to have multiple "new" object expressions and mixed scalar results. Suppose you create a query as such: ``` dql SELECT new UserDTO(u.id,u.name) as user,new AddressDTO(a.street,a.postalCode) as address, a.id as addressId FROM User u INNER JOIN u.addresses a WITH a.isPrimary = true ``` upon executing this query, you'll end up with a result set that looks like the following: ``` php array( 0=>array( 0=>{UserDTO object}, 1=>{AddressDTO object}, 2=>{u.id scalar}, 3=>{u.name scalar}, 4=>{a.street scalar}, 5=>{a.postalCode scalar}, 'addressId'=>{a.id scalar}, ), ... ) ``` My changes fix that so you'd end up with a more usable result set: ``` php array( 0=>array( 'user'=>{UserDTO object}, 'address'=>{AddressDTO object}, 'addressId'=>{a.id scalar} ) ... ) ```
admin added the Bug label 2026-01-22 14:36:19 +01:00
admin closed this issue 2026-01-22 14:36:19 +01:00
Author
Owner

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

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1171] was merged:
https://github.com/doctrine/doctrine2/pull/1171

@doctrinebot commented on GitHub (Jan 13, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1171] was merged: https://github.com/doctrine/doctrine2/pull/1171
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4159