Fraction doesn't work with views SUM aggregation

Created on 5 April 2012, about 13 years ago
Updated 4 April 2025, 2 days ago

In previous dev versions, I had modified the "transactions by account" view to group by Transaction:Description and SUM (Account Entry:Value). In the latest version, when I turn aggregation on, the resulting SQL does not have any GROUP BY or SUM printed in the query. Is this a bug or a consequence of the schema design?

Kevin

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Beakerboy Kentucky

Live updates comments and jobs are added and updated live.
  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • πŸ‡¦πŸ‡ΊAustralia elc

    I've been using this patch to fix up SUM(fraction) successfully for years now, but it has just stopped working and I'm having problems narrowing it down to the exact failure. I haven't been able to narrow down the timeframe for when the failure happened either, except that it was either last week, or all the way back in January. It doesn't seem to line up with releases of this module.

    Key to it is that $field->field_alias == 'unknown' for all of the Fraction fields in a view. That was causing the complete failure of what this patch was doing.

    I've reworked the patch from #11 into 3.x-1515840-fix-sum to at least give me the correct answers in $view->results at hook_views_pre_render() time, but all of the fields are still considered empty and rendered as such. It seems very much like the field_alias being considered the default "unknown" by the field handler is the bugbear.

    I had to change ordering of the 'entity field' vs 'field_name' in field definition since every field now has 'field_name', even if it is an entity field. This was resulting in no fields being found for fraction base fields.

    The attempt to compensate for the field_alias being missing is not the correct way to go. Determining why that is missing is where I am currently focussed.

    I have not created a MR as this still needs work. Some additional eyeballs would be greatly appreciated. Dumping to 3.x branch.

  • πŸ‡ΊπŸ‡ΈUnited States m.stenta

    @elc What version of Drupal core and Fraction are you using?

    I wonder if this change has anything to do with it?

    https://git.drupalcode.org/project/fraction/-/commit/f34523b9fe859f80745...

    That is the only substantive change to the 2.x branch since January.

    Key to it is that $field->field_alias == 'unknown' for all of the Fraction fields in a view. That was causing the complete failure of what this patch was doing.

    Otherwise, I wonder if something changed in Drupal core / Views that could explain the new behavior you're seeing. πŸ€”

  • πŸ‡¦πŸ‡ΊAustralia elc

    Site is running Drupal 10.4.6 and Fraction 3.0.1.

    I've been searching Drupal Core for any related changes without any luck. I haven't figured out how field_alias is ending up either with no value set, or the value set being unknown. The field is present in the query while the alias is unknown, which is weird itself since there has already been an alias calculated as the array key, and set as a key in the array too.

    I'll reverse that commit and see if it makes any difference. First look is that it's only the category name that has changed. Hard pressed to think that would make a difference.

Production build 0.71.5 2024