Problem/Motivation

If a View is not aggregated, the field should not show an aggregation function.

Steps to reproduce

Add two fields.
Enable aggregation for the View.
Configure the aggregation settings for the second field, applying an "average" on the field.
Check the query to see "avg" on the field.
Disable aggregation.
Check the query: "avg" will still be on the field.

Proposed resolution

Add

    $use_aggregation = $this->view->display_handler->useGroupBy();
    $group_type = $use_aggregation ? $this->options['group_type'] : 'group';

    $params = $group_type != 'group' ? ['function' => $group_type] : [];

to the query method of the field.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andileco created an issue. See original summary.

andileco’s picture

Assigned: andileco » nikathone
Status: Active » Needs review
nikathone’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

andileco’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.