Problem/Motivation

When you have an entity that has a multi-value base field of a field type with multiple columns then you need to explicitly specify in your views data handler how each of the columns should be treated. This can be done with the following, for example:


class MyEntity extends EntityViewsData {

  protected function processViewsDataForMultiColumnFieldType($table, FieldDefinitionInterface $field_definition, array &$views_field, $field_column_name) {
    switch ($field_column_name) {
      case 'column_1':
        $views_field['field'] = ['id' => 'standard'];
        break;

      case 'column_2':
        $views_field['field'] = ['id' => 'numeric'];
        break;

    }

  }

}

This then leads to Views querying columns of the form field_name__column_1, for example. The actual column names have only a single underscore, though, so it should be field_name_column_1.

The culprit - as far as I can tell - is line 377 of EntityViewsData which does:

      $views_field_name = ($multiple) ? $field_name . '__' . $field_column_name : $field_name;

I think this ends up being used as the column name. I haven't yet figured out how, though.

This is mitigated by the fact that you can "fix" the incorrect table name by hand simply by declaring a 'real field' key:

    $views_field['real field'] = $field_definition->getName() . '_' . $field_column_name;

Proposed resolution

Fix the incorrect table name.

Remaining tasks

User interface changes

None.

API changes

Data model changes

Comments

tstoeckler created an issue. See original summary.

tstoeckler’s picture

Status: Active » Closed (duplicate)