[PR #1445] Allow access to Query#getResultSetMapping #9501

Closed
opened 2026-01-22 16:04:30 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/1445

State: closed
Merged: No


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 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? (works fine at first glance)

$rsm = $query->getResultSetMapping();
$rsm->addScalarResult(
    array_search('custom_field', $rsm->scalarMappings),
    'custom_field',
    'custom_type'
);

$query->setResultSetMapping($rsm);

Related: ea14bcff4a

Thanks!

**Original Pull Request:** https://github.com/doctrine/orm/pull/1445 **State:** closed **Merged:** No --- 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 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? (works fine at first glance) ``` php $rsm = $query->getResultSetMapping(); $rsm->addScalarResult( array_search('custom_field', $rsm->scalarMappings), 'custom_field', 'custom_type' ); $query->setResultSetMapping($rsm); ``` Related: https://github.com/doctrine/doctrine2/commit/ea14bcff4a2a78bf774e8847b6645dca112f9757 Thanks!
admin added the pull-request label 2026-01-22 16:04:30 +01:00
admin closed this issue 2026-01-22 16:04:31 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9501