Problem/Motivation
While working on #2976147: Create a sales report supporting daily, weekly, monthly, and yearly breakdowns., my tests failed due to configuration schema validation.
Schema errors for views.view.sales_report with the following errors: views.view.sales_report:display.default.display_options.fields.report_id.set_precision missing schema
The report_id
is the entity identifier base field. The View has aggregation enabled, and the report_id
is set to COUNT.
In Views, the handler is swapped to numeric as an override when the display is built. This is causing a SchemaIncompleteException exception to be thrown.
This following code is what changes the handler and causes the schema error
\Drupal\views\Plugin\views\display\DisplayPluginBase::getHandlers
// If aggregation is on, the group type might override the actual
// handler that is in use. This piece of code checks that and,
// if necessary, sets the override handler.
$override = NULL;
if ($this->useGroupBy() && !empty($info['group_type'])) {
if (empty($this->view->query)) {
$this->view->initQuery();
}
$aggregate = $this->view->query->getAggregationInfo();
if (!empty($aggregate[$info['group_type']]['handler'][$type])) {
$override = $aggregate[$info['group_type']]['handler'][$type];
}
}
Proposed resolution
No idea.
Remaining tasks
- Write test which aggregates an entity ID
- ???