Switching on aggregation generates fatal "Column not found: 1054 Unknown column" SQL error when using multi-column Fields

Created on 10 October 2016, over 7 years ago
Updated 21 April 2024, about 2 months ago

Problem/Motivation

Enabling aggregation can cause SQL errors. This happens when a fields that has multiple columns (like an image field) has been added to to the View. Views currently sets no default column for such fields and it has no fall back or catch for fields that have no group_column set.

Reproduction Instructions

(From #8 )

  1. Create new view for article or basic page
  2. Add fields title, body and image
  3. Enable views aggregation

Proposed resolution

Fix the field query so that this problem does not occur by adding better settings of defaults and adding a fall back for empty values.

Remaining tasks

  • Manual review of code

User interface changes

No UI changes.

API changes

No API changes.

Data model changes

No data model changes.

Original Bug Report

Created a view using content of type officers. Using taxonomy to designate a position for each officer. That field is set to unlimited.

The content title field is being used for the officer name, and there is a link field, which provides a link to each officer's contact form, each of which were created under Structure > Contact Form.

The Contact form link field is hidden in the view, and the title field is rewritten so that it displays the officer's name with a link to the contact form.

One officer has two positions, so I added the two positions to that particular officer's content item. The entry for the officer with two positions appeared twice in the view, so I turned aggregation to 'on,' which I understand it the tool to handle these types of situations.

I received the following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node__field_officer_contact_form.field_officer_contact_form_' in 'field list': SELECT node__field_officer_contact_form.field_officer_contact_form_ AS node__field_officer_contact_form_field_officer_contact_form_, node_field_data.title AS node_field_data_title, node__field_officer_position.field_officer_position_target_id AS node__field_officer_position_field_officer_position_target_i, taxonomy_term_field_data_node__field_officer_position.weight AS taxonomy_term_field_data_node__field_officer_position_weight, MIN(node_field_data.nid) AS nid, MIN(taxonomy_term_field_data_node__field_officer_position.tid) AS taxonomy_term_field_data_node__field_officer_position_tid FROM {node_field_data} node_field_data LEFT JOIN {node__field_officer_position} node__field_officer_position ON node_field_data.nid = node__field_officer_position.entity_id AND (node__field_officer_position.deleted = :views_join_condition_0 AND node__field_officer_position.langcode = node_field_data.langcode) INNER JOIN {taxonomy_term_field_data} taxonomy_term_field_data_node__field_officer_position ON node__field_officer_position.field_officer_position_target_id = taxonomy_term_field_data_node__field_officer_position.tid LEFT JOIN {node__field_officer_contact_form} node__field_officer_contact_form ON node_field_data.nid = node__field_officer_contact_form.entity_id AND (node__field_officer_contact_form.deleted = :views_join_condition_2 AND node__field_officer_contact_form.langcode = node_field_data.langcode) WHERE (( (node_field_data.status = :db_condition_placeholder_4) AND (node_field_data.type IN (:db_condition_placeholder_5)) )) GROUP BY node__field_officer_contact_form_field_officer_contact_form_, node_field_data_title, node__field_officer_position_field_officer_position_target_i, taxonomy_term_field_data_node__field_officer_position_weight ORDER BY taxonomy_term_field_data_node__field_officer_position_weight ASC; Array ( [:db_condition_placeholder_4] => 1 [:db_condition_placeholder_5] => officer [:views_join_condition_0] => 0 [:views_join_condition_2] => 0 )

and of course, the view will not display.

I can't take a close look at this now, but I thought I'd report it to the community. in case anyone else has encountered it. I will parse through the error message later to see if I can figure out what is going on.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Views 

Last updated less than a minute ago

Created by

🇺🇸United States RKopacz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024