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
Issue fork views_csv_source-3568593
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
Comment #3
nikathoneLooks good. The native iterator class should cover
\League\Csv\MapIteratorif passed.Comment #4
andileco commented