- πΊπΈUnited States bwong
This is essentially the same problem as #15022759 π the Value is lost with Aggregation Needs review which is for version 8.x. Hopefully I can get the fix I am working on for Drupal 8+ to work with 7.
If you are trying to use views aggregation, the aggregation of expression fields doesn't work. It doesn't wrap the expression with aggregation functions such as SUM, and it incorrectly adds the field to the GROUP BY clause.
After looking at the views_handler_field_views_raw_sql.inc file
I realised that you have bypassed the boilerplate query code which handles parameters (which seem to be used by the aggregation feature), so if you make the following changes, it seems to work for all aggregation functions except COUNT (which does weird things):
function query() {
// Make sure the table is available, and get the alias.
$table_alias = $this->ensure_my_table();
// Boilerplate from views_handler_field->query().
$params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array();
$this->field_alias = $this->query->add_field(NULL, $this->options['raw_sql'], 'raw_sql_field', $params);
// More boilerplate.
$this->add_additional_fields();
} // query
When you try to use the COUNT function, the Raw SQL form is changed to the default form and the custom expression is lost. I haven't worked out why this is happening.
Postponed: needs info
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
This is essentially the same problem as #15022759 π the Value is lost with Aggregation Needs review which is for version 8.x. Hopefully I can get the fix I am working on for Drupal 8+ to work with 7.