Column information not available for computed field

Created on 3 April 2024, 3 months ago
Updated 5 April 2024, 2 months ago

Problem/Motivation

When attempting to add a computed field in Views using the `HOOK_views_data_alter`, and referencing the computed field in the view, Drupal 10.2 throws a fatal error with the following message: "Column information not available for `computed_fieldname`".
Upon investigating this issue, it was discovered that the field storage definition (custom storage) is not properly checked when trying to retrieve the fieldColumnName. Since it is a computed field, this step fails and results in the fatal error.

Steps to reproduce

- Create a computed field.
- Create a Views hook for the computed field:

```
$data['node']['FIELD_NAME'] = [
'title' => t('FIELD_TITLE'),
'help' => t('FIELD_DESCRIPTION'),
'field' => [
'id' => 'field',
'default_formatter' => 'string',
'field_name' => 'FIELD_NAME',
],
];
```

Create a view that references this custom computed field.
Observe the fatal error on Drupal 10.2.

Proposed resolution

Apply the patch provided and address the encountered errors.

Remaining tasks

Review the code to ensure compliance with all necessary queries.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Viewsย  โ†’

Last updated about 3 hours ago

Created by

๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Remco Hoeneveld

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024