Problem/Motivation

When trying to add a "Constant Value" field in order to SUM() on a single column, I experienced the following error:

TypeError: Drupal\views_csv_source\Plugin\views\query\ViewsCsvQuery::aggregateWithConstant(): Argument #2 ($records) must be of type League\Csv\MapIterator, array given, called in /code/web/modules/contrib/views_csv_source/src/Plugin/views/query/ViewsCsvQuery.php on line 339 in Drupal\views_csv_source\Plugin\views\query\ViewsCsvQuery->aggregateWithConstant() (line 384 of /code/web/modules/contrib/views_csv_source/src/Plugin/views/query/ViewsCsvQuery.php).

Steps to reproduce

Add a file with a numeric column. Add that column to your view. Add a Constant Value field. Turn on aggregation, group on the Constant Value field and SUM the numeric column. Observe the logs.

Proposed resolution

We should definitely ensure that it accepts an array, as that is what was passed. We can also replace MapIterator with just Iterator, as that's what the execute() function provides.

Remaining tasks

Determine if we can reduce the number of possible types for $records.

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.

nikathone’s picture

Status: Active » Reviewed & tested by the community

Looks good. The native iterator class should cover \League\Csv\MapIterator if passed.

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.