DDC-3805: [GH-1445] Allow access to Query#getResultSetMapping #4662

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

Originally created by @doctrinebot on GitHub (Jul 1, 2015).

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 Padam87:

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

Message:

Hi,

I've recently came across an issue which would require modifying the result set mapping of a query made with query builder.

I would like to SUM a field with a _custom type_, which is stored as an int, but is normally converted to a custom value object.

When using an aggregation function, the returned result is a simple int.

Is there any reason the Query#getResultSetMapping has to be protected?

Is there any danger if I do this?

$rsm = $query->getResultSetMapping();
$rsm->addScalarResult('sclr_2', 'dailySpendLimit', 'bigMoney2Precision');

$query->setResultSetMapping($rsm);

Related: ea14bcff4a

Thanks!

Originally created by @doctrinebot on GitHub (Jul 1, 2015). 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 Padam87: Url: https://github.com/doctrine/doctrine2/pull/1445 Message: Hi, I've recently came across an issue which would require modifying the result set mapping of a query made with query builder. I would like to SUM a field with a **_custom type**_, which is stored as an int, but is normally converted to a custom value object. When using an aggregation function, the returned result is a simple int. Is there any reason the `Query#getResultSetMapping` has to be protected? Is there any danger if I do this? ``` php $rsm = $query->getResultSetMapping(); $rsm->addScalarResult('sclr_2', 'dailySpendLimit', 'bigMoney2Precision'); $query->setResultSetMapping($rsm); ``` Related: https://github.com/doctrine/doctrine2/commit/ea14bcff4a2a78bf774e8847b6645dca112f9757 Thanks!
admin added the Bug label 2026-01-22 14:47:02 +01:00
admin closed this issue 2026-01-22 14:47:04 +01:00
Author
Owner

@beberlei commented on GitHub (Feb 16, 2020):

Would it be possible to implement this with the NEW operator in DQL?

SELECT NEW CustomType(SUM(foo.id)) FROM Foo foo
@beberlei commented on GitHub (Feb 16, 2020): Would it be possible to implement this with the `NEW` operator in DQL? ``` SELECT NEW CustomType(SUM(foo.id)) FROM Foo foo ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4662