The views_handler_field_entity class does not include the aggregation language when it overrides views_handler_field's query method to add the entity id. This means that it is not possible to remove the entity id in question from the GROUP BY statement when building a view.
Case in point:
I am building a view of a content type which, by way of file_entity and media projects, uses several image files in each node. I am building a view which will return only the first of those for each node, along with title, teaser, etc. However, when selecting the MIN aggregation type for the Rendered File field I am using, it is not removed from the SQL statement's GROUP BY statement as it should be, resulting in multiple rows per node in the result set rather than the desired single row.
file_entity's views_handler_field_file_rendered class is extending views' views_handler_field_entity and inheriting the query method which is missing the aggregation language.
I don't have the history with this code to know if this was done intentionally or not, but I suspect a bug.
Comment | File | Size | Author |
---|---|---|---|
#2 | views-entity-object-aggregation-2385115-entity-object-aggregation.patch | 836 bytes | wayneloftus |
Comments
Comment #1
wayneloftus CreditAttribution: wayneloftus commentedBy way of illustration, the query method in the parent class looks like this:
In views_handler_field_entity, it looks like this:
The $params are not passed to add_field()
Comment #2
wayneloftus CreditAttribution: wayneloftus commentedProposed patch.