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

  • Write patch to fix the error
  • Manual testing of patch
  • Write automated test(s)
  • 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.

CommentFileSizeAuthor
#208 drupal-11.3.9.patch20.48 KBjan kellermann
#198 2815881-nr-bot_2ppquy5o.txt90 bytesneeds-review-queue-bot
#196 2815881-196.patch20.08 KBfernly
#193 2815881-193.patch49.01 KBfernly
#172 2815881-172.patch19.98 KBjsutta
#169 2815881-169.patch23.28 KBalexdoma
#162 reroll_diff_157-162.txt15.72 KBravi.shankar
#162 2815881-162.patch32.67 KBravi.shankar
#157 2815881-157.patch32.96 KBspokje
#157 interdiff_154-157.txt636 bytesspokje
#154 2815881-154.patch32.92 KBlendude
#154 interdiff-2815881-152-154.txt445 byteslendude
#152 2815881-152.patch32.31 KBlendude
#148 articleview-Content-Drush-Site-Install.png176.73 KBprasanth_kp
#148 Screenshot 2022-04-14 at 19-55-16 articleview (Content) Drush Site-Install.png262.35 KBprasanth_kp
#145 2815881-145.patch32.3 KBlendude
#145 interdiff-2815881-143-145.txt13.49 KBlendude
#143 2815881-143-9.3.x.patch32.53 KBseanb
#135 raw-diff-9.1.x-9.2.x.txt714 bytesjungle
#135 interdiff-121-135.txt9.35 KBjungle
#135 2815881-135-9.2.x.patch29.27 KBjungle
#135 2815881-135-9.1.x.patch29.08 KBjungle
#134 2815881-134-9.1.x.patch28.54 KBjungle
#133 interdiff-121-132.txt8.74 KBjungle
#133 2815881-132.patch28.73 KBjungle
#128 interdiff_121-128.txt14.95 KBmohrerao
#128 2815881-128.patch18.37 KBmohrerao
#122 Screenshot 2020-06-02 at 3.01.05 PM.png172.71 KBsharma.amitt16
#121 2815881-121.patch32.04 KBnarendra.rajwar27
#121 interdiff_2815881_117-121.txt12.29 KBnarendra.rajwar27
#118 interdiff_2815881_117-118.txt10.85 KBnarendra.rajwar27
#118 2815881-118.patch32.04 KBnarendra.rajwar27
#117 interdiff_2815881_110-117.txt972 bytesnarendra.rajwar27
#117 2815881-117.patch32.03 KBnarendra.rajwar27
#115 2815881-115.patch31.5 KBnarendra.rajwar27
#115 interdiff_2815881_110-115.txt582 bytesnarendra.rajwar27
#110 2815881-110.patch31.62 KBsokru
#105 2815881-105.patch31.75 KBakashkumar07
#104 2815881-104.patch31.69 KBakashkumar07
#103 2815881-103.patch31.72 KBakashkumar07
#103 2815881-103.patch31.72 KBakashkumar07
#97 2815881-97.patch31.51 KBvacho
#92 2815881-92.patch31.47 KBpancho
#92 2815881_91-92_interdiff.txt1.57 KBpancho
#91 2815881-91.patch31.44 KBpancho
#91 2815881_90-91_interdiff.txt3.94 KBpancho
#90 2815881-90.patch31.25 KBpancho
#90 2815881_89-90_interdiff.txt523 bytespancho
#89 2815881-89.patch31.23 KBpancho
#89 2815881_88-89_interdiff.txt1.38 KBpancho
#88 2815881-88.patch31.17 KBpancho
#88 2815881_87-88_interdiff.txt3.35 KBpancho
#87 2815881-87.patch31.13 KBpancho
#87 2815881_84-87_diff.txt1.21 KBpancho
#84 2815881-84-8.6.x.patch31.13 KBpancho
#84 2815881_82-84_interdiff.txt1.74 KBpancho
#82 2815881-82-8.6.x.patch31.05 KBpancho
#82 2815881_80-82_interdiff.txt1.32 KBpancho
#80 2815881-80-8.6.x.patch29.86 KBpancho
#80 2815881_66-80_interdiff.txt3.92 KBpancho
#79 2815881_66-72_interdiff.txt6.67 KBpancho
#76 Screen Shot 2018-10-29 at 8.41.53 PM.png132.28 KBjosueValRob
#76 Screen Shot 2018-10-29 at 8.41.59 PM.png218.53 KBjosueValRob
#74 2815881-74-8.5.x.patch29.75 KBseanb
#72 2815881-72-8.5.x.patch29.81 KBmanojapare
#66 2815881-66-8.5.x.patch29.87 KBlendude
#66 2815881-62-8.4.x.patch29.88 KBlendude
#62 2815881-62-8.5.x.patch30.37 KBlendude
#62 2815881-62-8.4.x.patch29.88 KBlendude
#62 interdiff-2815881-55-62.txt3.95 KBlendude
#56 2815881-55.patch29.68 KBlendude
#56 interdiff-2815881-47-55.txt4.04 KBlendude
#51 2815881- after patch 47.png68.27 KBsonona
#51 2815881- before patch 47.png111.49 KBsonona
#47 2815881-47.8.4.x.patch27.1 KBlendude
#47 2815881-46.8.3.x.patch27.19 KBlendude
#46 2815881-46.8.4.x.patch29.47 KBlendude
#46 2815881-46.8.3.x.patch27.19 KBlendude
#43 2815881-43-8.4.x.patch27.11 KBlendude
#43 2815881-43-8.3.x.patch27.21 KBlendude
#39 2815881-39-8.4.x.patch27.15 KBlendude
#39 2815881-39-8.3.x.patch27.25 KBlendude
#39 interdiff-2815881-38-39.txt612 byteslendude
#38 2815881-38-8.4.x.patch27.15 KBlendude
#38 2815881-38-8.3.x.patch27.25 KBlendude
#38 interdiff-2815881-35-38.txt1.99 KBlendude
#35 2815881-35.patch27.26 KBlendude
#35 interdiff-2815881-34-35.txt1.1 KBlendude
#34 2815881-34.patch27.26 KBlendude
#34 interdiff-2815881-32-34.txt13.21 KBlendude
#32 2815881-32.patch13.42 KBlendude
#32 2815881-32-TEST_ONLY.patch4.29 KBlendude
#28 2815881-28.patch9.13 KBlendude
#28 interdiff-2815881-25-28.txt1.21 KBlendude
#25 interdiff-2815881-22-25.txt2.23 KBmanojapare
#25 2815881-25.patch8.13 KBmanojapare
#22 2815881-22-complete.patch6.09 KBjofitz
#22 2815881-22-test_only.patch5.12 KBjofitz
#19 Screen Shot 2017-01-30 at 18.16.21.png31.19 KBjohn cook
#19 Screen Shot 2017-01-30 at 18.14.43.png189.3 KBjohn cook
#18 interdiff-2815881-16-18.txt1.55 KBmanojapare
#18 2815881-18.patch988 bytesmanojapare
#16 interdiff-2815881-14-16.txt852 bytesmanojapare
#16 2815881-16.patch964 bytesmanojapare
#14 interdiff-2815881-10-14.txt552 bytesmanojapare
#14 2815881-14.patch984 bytesmanojapare
#10 2815881-10.patch618 bytesmanojapare
#8 Aggregation-group-column.png30.73 KBmanojapare
#8 Aggregation-settings.png12.34 KBmanojapare

Issue fork drupal-2815881

Command icon 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

RKopacz created an issue. See original summary.

lendude’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

It's trying to find a field field_officer_contact_form_ on the contact form entity. Does this exist? Is this an entity reference field to a contact form entity or something else? I'm just trying to get a feel of which parts of core are involved in this.

Maybe you can attach a yml export of this particular view config? That might help us identify the components involved in this.

RKopacz’s picture

Here is the configuration Export file for the view:

uuid: 7909e24c-4092-4986-b06b-3e8d586927ca
langcode: en
status: true
dependencies:
  config:
    - field.storage.node.field_officer_contact_form
    - field.storage.node.field_officer_position
    - node.type.officer
    - system.menu.main
  module:
    - link
    - node
    - taxonomy
    - user
id: officers_sort_page
label: Officers
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
  default:
    display_plugin: default
    id: default
    display_title: Master
    position: 0
    display_options:
      access:
        type: perm
        options:
          perm: 'access content'
      cache:
        type: tag
        options: {  }
      query:
        type: views_query
        options:
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_comment: ''
          query_tags: {  }
      exposed_form:
        type: basic
        options:
          submit_button: Apply
          reset_button: false
          reset_button_label: Reset
          exposed_sorts_label: 'Sort by'
          expose_sort_order: true
          sort_asc_label: Asc
          sort_desc_label: Desc
      pager:
        type: none
        options:
          items_per_page: 0
          offset: 0
      style:
        type: table
        options:
          grouping: {  }
          row_class: ''
          default_row_class: true
          override: true
          sticky: false
          caption: ''
          summary: ''
          description: ''
          columns:
            field_officer_contact_form: field_officer_contact_form
            title: title
            field_officer_position: field_officer_position
          info:
            field_officer_contact_form:
              align: ''
              separator: ''
              empty_column: false
              responsive: priority-low
            title:
              sortable: false
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
            field_officer_position:
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
          default: '-1'
          empty_table: false
      row:
        type: fields
        options:
          default_field_elements: true
          inline:
            title: title
            field_officer_position: field_officer_position
          separator: ', '
          hide_empty: false
      fields:
        field_officer_contact_form:
          id: field_officer_contact_form
          table: node__field_officer_contact_form
          field: field_officer_contact_form
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: true
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: uri
          type: link
          settings:
            trim_length: 80
            url_only: true
            url_plain: true
            rel: '0'
            target: '0'
          group_column: ''
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          plugin_id: field
        title:
          id: title
          table: node_field_data
          field: title
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: true
            text: '<a href="{{ field_officer_contact_form }}" target="_blank">{{ title }}</a>'
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: false
            ellipsis: false
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: value
          type: string
          settings:
            link_to_entity: false
          group_column: value
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          entity_type: node
          entity_field: title
          plugin_id: field
        field_officer_position:
          id: field_officer_position
          table: node__field_officer_position
          field: field_officer_position
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: target_id
          type: entity_reference_label
          settings:
            link: false
          group_column: target_id
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          plugin_id: field
        edit_node:
          id: edit_node
          table: node
          field: edit_node
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          text: edit
          entity_type: node
          plugin_id: entity_link_edit
      filters:
        status:
          value: true
          table: node_field_data
          field: status
          plugin_id: boolean
          entity_type: node
          entity_field: status
          id: status
          expose:
            operator: ''
          group: 1
        type:
          id: type
          table: node_field_data
          field: type
          value:
            officer: officer
          entity_type: node
          entity_field: type
          plugin_id: bundle
      sorts:
        weight:
          id: weight
          table: taxonomy_term_field_data
          field: weight
          relationship: field_officer_position
          group_type: group
          admin_label: ''
          order: ASC
          exposed: false
          expose:
            label: ''
          entity_type: taxonomy_term
          entity_field: weight
          plugin_id: standard
      title: Contacts
      header:
        area:
          id: area
          table: views
          field: area
          relationship: none
          group_type: group
          admin_label: ''
          empty: false
          tokenize: false
          content:
            value: "Click on an individual's name to send them a message.\n<br/>\n<br/>"
            format: full_html
          plugin_id: text
      footer: {  }
      empty: {  }
      relationships:
        field_officer_position:
          id: field_officer_position
          table: node__field_officer_position
          field: field_officer_position
          relationship: none
          group_type: group
          admin_label: 'field_officer_position: Taxonomy term'
          required: true
          plugin_id: standard
      arguments: {  }
      display_extenders: {  }
    cache_metadata:
      max-age: 0
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - 'user.node_grants:view'
        - user.permissions
      tags:
        - 'config:field.storage.node.field_officer_contact_form'
        - 'config:field.storage.node.field_officer_position'
  block_1:
    display_plugin: block
    id: block_1
    display_title: Block
    position: 2
    display_options:
      display_extenders: {  }
    cache_metadata:
      max-age: 0
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - 'user.node_grants:view'
        - user.permissions
      tags:
        - 'config:field.storage.node.field_officer_contact_form'
        - 'config:field.storage.node.field_officer_position'
  page_1:
    display_plugin: page
    id: page_1
    display_title: Page
    position: 1
    display_options:
      display_extenders: {  }
      path: contacts
      menu:
        type: normal
        title: Contacts
        description: ''
        expanded: false
        parent: ''
        weight: -46
        context: '0'
        menu_name: main
    cache_metadata:
      max-age: 0
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - 'user.node_grants:view'
        - user.permissions
      tags:
        - 'config:field.storage.node.field_officer_contact_form'
        - 'config:field.storage.node.field_officer_position'

The contact form is added to the officer content type using a link field. Might that be the problem? I am rewriting the title field to be a link to the contact form, so that link field is hidden in the display. Some officers hold more than one position, so those officers repeat in the list. The standard way of eliminating that display is aggregation. Turning on aggregation caused the problem.

Should I use the entity reference instead?

RKopacz’s picture

Okay, so I added the Contact form as an entity reference field. I then tried to create a relationship, and as soon as I created it, I received this error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'rosenet_wp._node__field_test' doesn't exist: SELECT taxonomy_term_field_data_node__field_officer_position.weight AS taxonomy_term_field_data_node__field_officer_position_weight, node_field_data.nid AS nid, 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_test} node__field_test ON node_field_data.nid = node__field_test.entity_id AND (node__field_test.deleted = :views_join_condition_2 AND node__field_test.langcode = node_field_data.langcode) LEFT JOIN {} _node__field_test ON node__field_test.field_test_target_id = _node__field_test.id WHERE (( (node_field_data.status = :db_condition_placeholder_4) AND (node_field_data.type IN (:db_condition_placeholder_5)) )) 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 )

Bug? Why does it say the table does not exist when I just created the reference and populated the fields on the existing nodes with references?

I'm trying to get relationship to the referenced form because my main goal is to get the path to the contact form, so that I can rewrite the title of the node that is the subject of the view as a link to that contact form. But I can't even seem to create that relationship in the view.

RKopacz’s picture

Anybody have any thoughts on this? I'm facing it for a third time when I try to turn on aggregation on views. Unkown column for a field, but the field is in the field list.

lendude’s picture

@RKopacz well some clear steps to reproduce with a vanilla core install would be the best thing to get this moving. That way we can write some tests for this and fix this. Cause something is not right here, but what.

You say you have seen this multiple times, but was it always related to a view using the contact form in some way?

RKopacz’s picture

@Lendude, thanks for the message. It is always happening when another entity is referenced, and when I am trying to use a field in the display from that entity. In the most recent case, it was a reference to a content entity that I had created, which was just a simple field on a node, for which I created a relationship to display one of the fields in the referenced entity. Since I referenced more than one entity in that field for one of the referencing nodes, the referencing node appeared twice in the list. I then tried to aggregate. But the SQL error message, when it popped up was nagging about a file field on the referencing node. That's also a reference in 8, but I did not create a relationship to it, because I did not think I needed to. Might that be it?

The prior time, it was a reference to a taxonomy term, where I had more than one term per node, and when I tried to display the taxonomy term in the node, the node appeared twice. But SQL was nagging me then about a link field that contained a relative URL to the contact form. After your post in #2, I tried the contact form as a reference field, but still got the same problem.

It could very well be a configuration issue that I am not considering in 8.

I will definitely try the vanilla core install, perhaps on Sunday, and see what else pops up.

manojapare’s picture

StatusFileSize
new12.34 KB
new30.73 KB

The same issue I faced, after some hours of digging I found that it is due to field aggregation settings. But this is not happening for all fields, only for field having multiple columns value like image having columns target_id, alt, title, height and width.

These are the steps to reproduce the issue:

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

For now I solved by just saving the image field aggregation settings:
Aggregation-settings.png

Aggregation-group-column.png

I know this is not a permanent solution. Will try to fix it and give a patch for the same.

manojapare’s picture

Status: Postponed (maintainer needs more info) » Needs review
manojapare’s picture

StatusFileSize
new618 bytes
rakesh.gectcr’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +SprintWeekend2017

Patch applies fine and it works, So making it RTBC. Would love to see what Core maintainers / View maintainer @dawehner says.

lendude’s picture

Version: 8.1.10 » 8.2.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs steps to reproduce +Needs tests

@manojapare nice work finding some steps to reproduce! Tested the steps and indeed there is an error when using an image field. A node ref didn't have any problems.

So if I understand correctly, the reason this happens is because there is no default value for the aggregation? And by saving the settings, a value gets set, and the problem goes away.

+++ b/core/modules/views/src/Plugin/views/field/Field.php
@@ -232,7 +232,7 @@ public function query($use_groupby = FALSE) {
+    if ($use_groupby && !empty($this->options['group_column'])) {

So this would mean that $fields doesn't get set and the call to $this->addAdditionalFields($fields); will add all additional fields.
Is there no way to set a proper default? Because defaulting to 8 fields getting added (in the case of an image field) to the query also doesn't sound great. And there is really no way to tell that this is happening other then looking at the query that was build.

Also this will need some tests.

lendude’s picture

Oh and this will need a separate patch for 8.3.x because the handler got renamed to \Drupal\views\Plugin\views\field\EntityField (but no need to worry about that yet)

manojapare’s picture

Status: Needs work » Needs review
StatusFileSize
new984 bytes
new552 bytes

@Lendude That's a good catch. Yeah as you commented $this->addAdditinalFields() adding all additional fields. So as per my observation to prevent it we need to make it run similarly when aggregation is not set.

Below patch will avoid adding all additional fields if group_column for the filed is not set.

rakesh.gectcr’s picture

Status: Needs review » Needs work

In case of aggregation not set and multiple value field, if ($this->add_field_table($use_groupby) && !empty($this->options['group_column'])) condition statements won't be executing. But those need to be executed in the same case

manojapare’s picture

Status: Needs work » Needs review
StatusFileSize
new964 bytes
new852 bytes

@rakesh.gectcr Thanks for the quick review.

Please review the latest patch.

john cook’s picture

Version: 8.2.x-dev » 8.3.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

I can confirm that the work around of editing the Image's aggregation settings will fix the problem.

But I tried to apply patch #16 but fails to apply.

$ git apply -v 2815881-16.patch
Checking patch core/modules/views/src/Plugin/views/field/Field.php...
error: while searching for:
      unset($fields[$entity_type_key]);
    }

    if ($use_groupby) {
      // Add the fields that we're actually grouping on.
      $options = array();
      if ($this->options['group_column'] != 'entity_id') {

error: patch failed: core/modules/views/src/Plugin/views/field/Field.php:232
error: core/modules/views/src/Plugin/views/field/Field.php: patch does not apply

As 8.2.x is no longer in development, upping the version to 8.3.x and adding "Needs reroll" tag.

manojapare’s picture

Status: Needs work » Needs review
StatusFileSize
new988 bytes
new1.55 KB

@john-cook The patch is failling to apply on 8.3.x branch beacuse Drupal\views\Plugin\views\field is been deprecated and instead we need to use Drupal\views\Plugin\views\field\EntityField.

Please find and review the rerolled patch for 8.3.x branch.

john cook’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll
StatusFileSize
new189.3 KB
new31.19 KB

I've tested patch #18 against 8.4.x.

The patch does prevent the SQL error from appearing.

Before:

After:

I cannot see any problems with the code.

I would set this to RTBC but there still needs to be a test created to ensure that this isn't reverted. Because of this I'm setting this back to Needs work but removing the Needs re-roll tag.

john cook’s picture

Issue summary: View changes

Tidied issue summary.

manojapare’s picture

I don't have any experience in writing test in Drupal. Can someone guide me or give documentation on how to write tests.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.12 KB
new6.09 KB

Here is a rather clumsy (but effective, nonetheless) pair of tests for the proposed change. This should at least give you something to start from.

The last submitted patch, 22: 2815881-22-test_only.patch, failed testing.

manojapare’s picture

Status: Needs review » Needs work

Thanks Jo Fitzgerald this one is very useful to start with PHPUnit.

I am changing the status to `Needs work` because in unit test one more condition in add_field_table need to be covered.

manojapare’s picture

Status: Needs work » Needs review
StatusFileSize
new8.13 KB
new2.23 KB

I have written unit test for covering the missed condition in add_field_table method to ensure that this scenario is handled in future as well. Once again thanks to Jo Fitzgerald.

Please review it.

lendude’s picture

Status: Needs review » Needs work

I like the test coverage here, but still not convinced by the fix. To me, the underlying problem is that apparently no default gets set in \Drupal\views\Plugin\views\field\EntityField::defineOptions. Why doesn't the image field/entity ref get a default?

This fix leads to all columns getting added, which might be nice as a last resort, but for a frequently used field type we need to look at getting the right default too I feel.

manojapare’s picture

@Lendude, Thanks for reviewing the patch. I too wondered the same question: Why doesn't the image field/entity ref get a default?

These are my findings for the same:

  1. In \Drupal\views\Plugin\views\field\EntityField::defineOptions all column names are been obtained from field storage definition.
  2. $default_column is been determined by this code,
    // Try to determine a sensible default.
        if (count($column_names) == 1) {
          $default_column = $column_names[0];
        }
        elseif (in_array('value', $column_names)) {
          $default_column = 'value';
        }
  3. Using $default_column only $options['group_column'] is been set as
    $options['group_column'] = array(
          'default' => $default_column,
        );

In case of normal fields say node title, $column_names = ['value']. But in case image field, $column_names = ['target_id', 'alt', 'title', 'width', 'height']. Hence for image/entity ref $default_column will be empty string which in-turn causes the problem.

I even tried just changing the code for determining default column in \Drupal\views\Plugin\views\field\EntityField::defineOptions like below:

   // Try to determine a sensible default.
    if (in_array('value', $column_names)) {
      $default_column = 'value';
    }
    elseif (count($column_names) >= 1) {
      $default_column = $column_names[0];
    }

which will set default_column for any field having additional fields. But this is also not solving the issue.

Let me know if this is not the way to debug or to fix it.

lendude’s picture

Issue tags: +Needs tests, +Needs upgrade path, +Needs upgrade path tests
StatusFileSize
new1.21 KB
new9.13 KB

I would do something like this. This only works for fields that have been added after applying the patch, existing fields will have a empty default.
This will need an integration level test.

And depending on what we want to do here, it will also need an upgrade path to fix the existing field defaults. Optionally we can not do an upgrade path and let the existing fields use the fallback introduced here for fields that we can't determine a default column for. But I would say an upgrade path would be the way to go here.

lendude’s picture

Status: Needs work » Needs review
manojapare’s picture

@Lendude, This is working fine.

But still I am wondering, why even after setting default_column and hence options['group_column'] the error is been not fixed.

lendude’s picture

@manojapare because the default gets set when you add the field to the View. So any existing fields will already have the wrong default, but newly added fields will work with the new default.

lendude’s picture

Issue tags: -Needs tests
StatusFileSize
new4.29 KB
new13.42 KB

New test. Test only patch only contains the new test and is the interdiff.

This still needs an upgrade path.

The last submitted patch, 32: 2815881-32-TEST_ONLY.patch, failed testing.

lendude’s picture

Issue tags: -Needs upgrade path, -Needs upgrade path tests
StatusFileSize
new13.21 KB
new27.26 KB

Upgrade path and test.

lendude’s picture

StatusFileSize
new1.1 KB
new27.26 KB

Quick cleanup.

lendude’s picture

Title: Aggregation on setting generates fatal " Column not found: 1054 Unknown column" SQL error » Swtiching on aggregation on generates fatal " Column not found: 1054 Unknown column" SQL error when using multi-column Fields
Issue summary: View changes

Updated the I.S. to reflect the current fix.

dawehner’s picture

+++ b/core/modules/views/src/Plugin/views/field/EntityField.php
@@ -344,13 +344,16 @@ protected function defineOptions() {
+      if (count($column_names) == 1) {
+        $default_column = $column_names[0];
+      }
+      elseif (in_array('value', $column_names)) {
+        $default_column = 'value';
+      }

Well, and otherwise choose the first available column?

lendude’s picture

StatusFileSize
new1.99 KB
new27.25 KB
new27.15 KB

Well, and otherwise choose the first available column?

Sounds good, but then we can just 'else' to the first column if 'value' isn't found. So something like this.

8.3 version won't apply to 8.4, so 2 versions.

lendude’s picture

StatusFileSize
new612 bytes
new27.25 KB
new27.15 KB

Missed a little cleanup.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
  1. +++ b/core/modules/views/src/Plugin/views/field/EntityField.php
    @@ -348,12 +348,12 @@
    -      if (count($column_names) == 1) {
    -        $default_column = $column_names[0];
    -      }
    -      elseif (in_array('value', $column_names)) {
    +      if (in_array('value', $column_names)) {
             $default_column = 'value';
           }
    +      else {
    +        $default_column = $column_names[0];
    +      }
    

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 39: 2815881-39-8.4.x.patch, failed testing.

lendude’s picture

lendude’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new27.21 KB
new27.11 KB

Rerolled

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Just a reroll, the world is still green.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 43: 2815881-43-8.4.x.patch, failed testing.

lendude’s picture

Title: Swtiching on aggregation on generates fatal " Column not found: 1054 Unknown column" SQL error when using multi-column Fields » Switching on aggregation on generates fatal " Column not found: 1054 Unknown column" SQL error when using multi-column Fields
Status: Needs work » Needs review
Issue tags: +DevDaysSeville
StatusFileSize
new27.19 KB
new29.47 KB

And another reroll...

lendude’s picture

StatusFileSize
new27.19 KB
new27.1 KB

Added a test view from another issue to the 8.4.x version, duh! 8.3.x didn't change but re-uploading to keep them together

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Another re-RTBC

imiksu’s picture

Issue tags: +Needs screenshots

Can we have before & after screenshots?

craigada’s picture

Assigned: Unassigned » craigada
sonona’s picture

StatusFileSize
new111.49 KB
new68.27 KB

Please see before and after screenshots

Before patch

After patch

sonona’s picture

Issue tags: -Needs screenshots
alexpott’s picture

Status: Reviewed & tested by the community » Needs review

I think we need to do a fix in Views::preSave() too. Similar to what we did in #2248983: Define the revision metadata base fields in the entity annotation in order for the storage to create them only in the revision table so views from a modules config/install or config/optional folder are fixed too? No?

There's really nice test coverage on this patch.

craigada’s picture

Assigned: craigada » Unassigned
lendude’s picture

I think we need to do a fix in Views::preSave() too.

@alexpott yes, you are of course correct.

Added a private function called in preSave(), the actual changes are done by that function when running post_update so the upgrade test covers both the post_update and the preSave()

lendude’s picture

StatusFileSize
new4.04 KB
new29.68 KB

now with the actual patch....

Status: Needs review » Needs work

The last submitted patch, 56: 2815881-55.patch, failed testing.

lendude’s picture

Status: Needs work » Needs review

That is the 8.4.x version, will roll a 8.3.x version if this lands

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

manojapare’s picture

Status: Needs review » Reviewed & tested by the community

Tested in 8.4.x branch, working fine and unit test and coverage looks fine. Marking as RTBC, even though found usage of 2 deprecated methods fixTableNames() and fixEmptyGroupColumn() in preSave () of View entity class.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Great work on the update path and tests!

I found something small that needs fixing here:

+++ b/core/modules/views/src/Entity/View.php
@@ -347,6 +348,50 @@ private function fixTableNames(array &$displays) {
+   * Fixes empty group columns.
+   *
+   * Some fields could be saved without a group column, this assures that every
+   * field has a default group column.
+   *
+   * @deprecated in Drupal 8.3.0, will be removed in Drupal 9.0.0.

Private and deprecated is a strategy I haven't seen before for an update helper. Seems reasonable. I guess fixTableNames() is the same.

However, we need to update the version here (not 8.3.0 anymore) and we should also add a @trigger_error() in the code path for it. (Probably just the top of the function.)

Queuing SQLite and PostgreSQL tests for this as well.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new3.95 KB
new29.88 KB
new30.37 KB

Updated the version, added the trigger_error, changed the update test to a BTB test

manojapare’s picture

Queuing SQLite and PostgreSQL test for both 8.4.x and 8.5.x

manojapare’s picture

Status: Needs review » Reviewed & tested by the community

@lendude Good job. Both patch for 8.4.x and 8.5.x applies fine and it is working fine. Making it RTBC.

Would like to see what Core maintainers says.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 62: 2815881-62-8.5.x.patch, failed testing. View results

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new29.88 KB
new29.87 KB

Needed another reroll, 8.4.x was still good, reupping to keep everything together

manojapare’s picture

Status: Needs review » Reviewed & tested by the community

Both patch for 8.4.x and 8.5.x applies fine and it is working fine. Making it Re - RTBC.

catch’s picture

Status: Reviewed & tested by the community » Needs review
  1. +++ b/core/modules/views/src/Entity/View.php
    @@ -344,6 +345,51 @@ private function fixTableNames(array &$displays) {
    +   */
    +  private function fixEmptyGroupColumn() {
    +    @trigger_error(__METHOD__ . ' is deprecated in version 8.4 and will be removed before 9.0.0.', E_USER_DEPRECATED);
    +    /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
    

    I think the trigger_error() should not be at the top of the function since we always run it unconditionally. It's not actually deprecated code, it's a bc layer which is a bit different.

  2. +++ b/core/modules/views/src/Entity/View.php
    @@ -344,6 +345,51 @@ private function fixTableNames(array &$displays) {
    +        foreach ($display['display_options']['fields'] as $field_name => &$field) {
    +          // Only update fields that have group_column set to an empty value.
    +          if (!empty($field['plugin_id']) && $field['plugin_id'] == 'field' && isset($field['group_column']) && empty($field['group_column'])) {
    +            // Attempt to load the field storage definition of the field.
    

    Instead shouldn't we put it here so it only runs when there's a View that needs fixing?

manojapare’s picture

@catch,

Let me revamp the points to make sure I got your points. First of all, this method is been called for all view irrespective of view needs fixing or not. And this method is part of bc layer and not a deprecated one.

Based on the above point you are suggesting to trigger deprecation error only when the view needs actual fixing.

IMHO. Here the whole method is part of bc layer not just a part of it. So we need to trigger deprecation unconditionally all the time.

tstoeckler’s picture

+++ b/core/modules/views/src/Plugin/views/field/EntityField.php
@@ -354,13 +354,16 @@ protected function defineOptions() {
+    // Try to determine a sensible default if none if provided by the field
+    // definition.
+    if (!$default_column) {
+      if (in_array('value', $column_names)) {
+        $default_column = 'value';
+      }
+      else {
+        $default_column = $column_names[0];
+      }
     }

Sorry for jumping in here so late, but are we sure this is needed? If a field type decides not to have a main property I think we should respect that. And since even before you can run into cases where $default_column is empty, I don't really understand why we do so much magic. Or is that precisely the bug here? (It's a bit hard to tell) If the latter is the case, I think we should at least drop the hardcoding of a "value" column and just always use the first one.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

manojapare’s picture

StatusFileSize
new29.81 KB

Re-rolled the patch for 8.5.x. Also made changes as per @tstoeckler suggestion.

Status: Needs review » Needs work

The last submitted patch, 72: 2815881-72-8.5.x.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

seanb’s picture

StatusFileSize
new29.75 KB

Straight up rerolled #66 for 8.5.x. For some reason creating an interdiff was not possible so here is just the patch.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

josueValRob’s picture

Anyone has tested it with rest views?.

I am facing a similar problem:

I have a rest view of a taxonomy term (books) and wants to add a contextual filter by the category. /books/drama. To do that, I add the relationship with the taxonomy term category and all the content get's duplicate. To fix it, I enable the aggregation but PUM! an SQL error.

Any idea?.

Drupal 8.6

biigniick’s picture

I think I'm having this issue too with 8.6
SQLSTATE[42S22]: Column not found: 1054 Unknown column

- Nick

pancho’s picture

Issue tags: +views aggregation

Let's get this one fixed, finally. Retesting the last patches, will then provide an interdiff and reroll against 8.6.x-dev.

pancho’s picture

StatusFileSize
new6.67 KB

First step: Here's the missing interdiff #66 -> #72, showing:

  • that @tstoeckler's suggestion per #70 was honored
  • that @catch's suggestion per #68 was ignored (and that's where all the test failures are coming from)
  • some minor, yet distracting code reorganization
pancho’s picture

Status: Needs work » Needs review
StatusFileSize
new3.92 KB
new29.86 KB

So here's another patch based on #66, yet taking into account both #68 and #70, and of course rerolled against 8.6.x-dev.

  1. As suggested by @catch in #68, I'm moving the @trigger_error further into the code, so an error is only triggered when a field's 'group_column' is actually set to an empty value ('').
  2. As suggested by @tstoeckler in #70, I'm removing the "magic 'value' column", instead always defaulting to the first column, if no main property is provided.
  3. Some minor code refactoring, hopefully not all to distracting to reviewers, yet bringing the logic in line in both places.

Let's see if we can bring the number of test fails down again.

Status: Needs review » Needs work

The last submitted patch, 80: 2815881-80-8.6.x.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

pancho’s picture

Status: Needs work » Needs review
StatusFileSize
new1.32 KB
new31.05 KB

Nice. So here I'm fixing the rather new media view and a test view, and codesniffer's CS fix.
Now there shouldn't be more than a handful of test fails.

Status: Needs review » Needs work

The last submitted patch, 82: 2815881-82-8.6.x.patch, failed testing. View results

pancho’s picture

Status: Needs work » Needs review
StatusFileSize
new1.74 KB
new31.13 KB

1.)
$display_name renamed to $display_id for clarity.

2.)

            $executable = $this->getExecutable();
            $executable->setDisplay($display_name);
            /** @var \Drupal\views\Plugin\views\field\FieldHandlerInterface $field_handler */
            $field_handler = $executable->getDisplay()->getHandler('field', $field['id']);

First thought we could get the handler for a particular display without setting and getting the display, but no we can't: #3034692: getHandler() != getHandler().

            /** @var \Drupal\views\Plugin\views\field\FieldHandlerInterface $field_handler */
            $field_handler = $this->getExecutable()->getHandler($display_id, 'field', $field['id']);

only gives me the handler configuration, not the actual handler object, so leaving everything as it is, except for the first two lines that can be chained.

3.)
This doesn't make any sense:

              $field_storage = NULL;
              if (isset($field['field']) && isset($field_storage_definitions[$field['field']])) {
                $field_storage = $field_storage_definitions[$field['field']];
              }
              // Use the field's main property as default column. If the field item does
              // not define a main property, use the first column as default column.
              $default_column = $field_storage->getMainPropertyName();
              if (empty($default_column)) {
                $column_names = array_keys($field_storage->getColumns());
                $default_column = $column_names[0];
              }

We can't do a getMainPropertyName() on NULL, neither can we do a getColumns() on NULL.
This is more correct:

              if (!isset($field['field']) || !isset($field_storage_definitions[$field['field']])) {
                continue;
              }
              $field_storage = $field_storage_definitions[$field['field']];
              // Use the field's main property as default column. If the field item does
              // not define a main property, use the first column as default column.
              $default_column = $field_storage->getMainPropertyName();
              if (empty($default_column)) {
                $column_names = array_keys($field_storage->getColumns());
                $default_column = $column_names[0];
              }

and hopefully enough.

4.)
Finally, following line was missing to make it all actually work:

              $field['group_column'] = $default_column;

Hope we got it right now. Let's have another test run to see how things turn out.

Status: Needs review » Needs work

The last submitted patch, 84: 2815881-84-8.6.x.patch, failed testing. View results

pancho’s picture

Title: Switching on aggregation on generates fatal " Column not found: 1054 Unknown column" SQL error when using multi-column Fields » Switching on aggregation generates fatal "Column not found: 1054 Unknown column" SQL error when using multi-column Fields
pancho’s picture

Version: 8.6.x-dev » 8.8.x-dev
StatusFileSize
new1.21 KB
new31.13 KB

Straight reroll against 8.8. Interdiff didn't work, so here's a plain diff.

pancho’s picture

StatusFileSize
new3.35 KB
new31.17 KB
            $executable = $this->getExecutable()->setDisplay($display_name);
            $field_handler = $executable->getDisplay()->getHandler('field', $field['id']);

can't work. My fault, introduced in #84, now reverted.

Also replaced the deprecated getMock() by createMock() in the tests we're introducing to Drupal\Tests\views\Unit\Plugin\field\FieldTest.

pancho’s picture

StatusFileSize
new1.38 KB
new31.23 KB
-              if (!empty($field_storage) && $field_storage->getMainPropertyName()) {
-                $field['group_column'] = $field_storage->getMainPropertyName();
-              }
-              elseif (!empty($field_storage)) {
+              $default_column = $field_storage->getMainPropertyName();
+              if (empty($default_column)) {

Another incorrect change, again my fault, introduced in #80, now reverted:
We're only attempting to load the field's storage.

pancho’s picture

StatusFileSize
new523 bytes
new31.25 KB
pancho’s picture

StatusFileSize
new3.94 KB
new31.44 KB

And following #3023981: Add @trigger_error() to deprecated EntityManager->EntityRepository methods, we need to replace $this->entityManager by $this->entityFieldManager and/or $this->entityTypeManager.
Now let's see if there's still something missing to make our bots happy... :)

pancho’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB
new31.47 KB

Nice, only deprecation notices left, which may now be suppressed by @group legacy.
I'm also pushing our new deprecation notice to Drupal 8.7.x, as I don't see this being cherrypicked into Drupal 8.6.x anymore.

Tested green locally, so finally ready for review!

divined’s picture

Hi! I don't know when it happens, but views don't display "list text" fields with enabled aggregation.

adam1’s picture

On Drupal 8.6.15 I ran into the above issue. But I couldn't find a working patch for this version. Could someone give me a hint which one to use?

super_romeo’s picture

#92 Patch Failed to Apply.

daffie’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
vacho’s picture

Issue tags: -Needs reroll
StatusFileSize
new31.51 KB

Patch rerolled.

tclark62’s picture

When I apply the patch, Hunk #1 for the file core/modules/views/tests/src/Kernel/QueryGroupByTest.php failed at 3, but everything else applies cleanly and it seems to fix the problem for me. Using 8.7.6, which may be the reason it didn't all apply cleanly.

mturner20’s picture

#97 worked for me! Thank you @vacho!

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

john cook’s picture

Issue tags: +Needs reroll

The patch from #97 does not apply to the 8.9.x branch. Another reroll is needed.

john cook’s picture

Issue tags: +Amsterdam2014, +Novice

Added "novice" tag for the reroll.

akashkumar07’s picture

Status: Needs work » Needs review
StatusFileSize
new31.72 KB
new31.72 KB

I have reroll the patch #97. Hope, this will solve the issue.

akashkumar07’s picture

StatusFileSize
new31.69 KB

This patch should fix the PHPLint Error.

akashkumar07’s picture

StatusFileSize
new31.75 KB

This patch should fix the PHPLint Error.

Status: Needs review » Needs work

The last submitted patch, 105: 2815881-105.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

ravi.shankar’s picture

Issue tags: -Needs reroll
drase15’s picture

Hi,

Anyone get success to install this patch?
If so someone can help me?
I'am installing this with composer

"extra": {
		"enable-patching": true,
		"patches" : {
			"drupal/core" : {
				"images aggregation": "https://www.drupal.org/files/issues/2019-07-26/2815881-97.patch"
			}
		},
}

After added that to my composer.json run command "composer install" and get an error:

"Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2019-07-26/2815881-97.patch"

I'm using #97 patch.

Or if anyone could solve this issue (image field with aggregation not working) with another solution please share.

Thanks in advance :)

super_romeo’s picture

Issue tags: +Needs reroll

Patch #97:

8.8.x: Patch Failed to Apply
sokru’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new31.62 KB

Reroll from #97.

Status: Needs review » Needs work

The last submitted patch, 110: 2815881-110.patch, failed testing. View results

mradcliffe’s picture

I performed Novice Triage on this issue. I am leaving the Novice tag on this issue because it looks like the test failures are pretty straightforward to fix.

Also I think the deprecation notices are out-of-date in the patch.

It would also be helpful to run the issue through the major issue triage process.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

narendra.rajwar27’s picture

Assigned: Unassigned » narendra.rajwar27
narendra.rajwar27’s picture

Version: 9.1.x-dev » 9.0.x-dev
Status: Needs work » Needs review
StatusFileSize
new582 bytes
new31.5 KB

Tried to apply comment #110 patch, but it is not getting applied in 8.9.x branch. Patch applied successfully in 8.8.x branch. So updating the patch for 8.9.x branch. For 9.1.x branch there is mismatch of code in files. I will update patch for 9.1.x after it passes for 8.9.x branch.

Status: Needs review » Needs work

The last submitted patch, 115: 2815881-115.patch, failed testing. View results

narendra.rajwar27’s picture

Status: Needs work » Needs review
StatusFileSize
new32.03 KB
new972 bytes

adding fix for failed test case

narendra.rajwar27’s picture

Version: 9.0.x-dev » 9.1.x-dev
StatusFileSize
new32.04 KB
new10.85 KB

Patch applied in Drupal9.1.x.

Status: Needs review » Needs work

The last submitted patch, 118: 2815881-118.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

narendra.rajwar27’s picture

Assigned: narendra.rajwar27 » Unassigned
narendra.rajwar27’s picture

Status: Needs work » Needs review
StatusFileSize
new12.29 KB
new32.04 KB

fix added for failed test cases.

sharma.amitt16’s picture

StatusFileSize
new172.71 KB

Tested patch #21 with 9.1.x branch. Before applying the patch, I am able to reproduce the error on drupal 9.1.0-dev.

Before applying the patch I got the error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node__field_image.field_image_' in 'field list': SELECT "node_field_data"."title" AS "node_field_data_title", "node__body"."body_value" AS "node__body_body_value", "node__field_image"."field_image_" AS "node__field_image_field_image_", "node_field_data"."created" AS "node_field_data_created", MIN(node_field_data.nid) AS "nid" FROM {node_field_data} "node_field_data" LEFT JOIN {node__body} "node__body" ON node_field_data.nid = node__body.entity_id AND (node__body.deleted = :views_join_condition_0 AND node__body.langcode = node_field_data.langcode) LEFT JOIN {node__field_image} "node__field_image" ON node_field_data.nid = node__field_image.entity_id AND (node__field_image.deleted = :views_join_condition_2 AND node__field_image.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_data_title, node__body_body_value, node__field_image_field_image_, node_field_data_created ORDER BY "node_field_data_created" DESC LIMIT 11 OFFSET 0; Array ( [:db_condition_placeholder_4] => 1 [:db_condition_placeholder_5] => article [:views_join_condition_0] => 0 [:views_join_condition_2] => 0 )

After applying patch #121, it solves the problem. It works well and giving an output of view with aggregation without any error.

After patch apply

lendude’s picture

+++ b/core/modules/views/src/Entity/View.php
@@ -293,6 +293,9 @@ public function preSave(EntityStorageInterface $storage) {
+    $this->fixEmptyGroupColumn();

@@ -305,6 +308,97 @@ public function preSave(EntityStorageInterface $storage) {
+  private function fixTableNames(array &$displays) {
...
+  private function fixEmptyGroupColumn() {

We now have ViewsConfigUpdater available to store these methods on, so let's move them there.

+++ b/core/modules/views/src/Entity/View.php
@@ -293,6 +293,9 @@ public function preSave(EntityStorageInterface $storage) {
+    $this->fixTableNames($displays);

@@ -305,6 +308,97 @@ public function preSave(EntityStorageInterface $storage) {
+  private function fixTableNames(array &$displays) {

This got added in #117 but has nothing to do with this issue, this needs to be removed again.

rajeev_drupal’s picture

Assigned: Unassigned » rajeev_drupal
rajeev_drupal’s picture

patch #121 works for. After applying the patch not getting SQL error.

rajeev_drupal’s picture

Assigned: rajeev_drupal » Unassigned
lendude’s picture

Status: Needs review » Needs work
mohrerao’s picture

Status: Needs work » Needs review
StatusFileSize
new18.37 KB
new14.95 KB

Fixed changes suggested in #123

lendude’s picture

Status: Needs review » Needs work
Issue tags: -Novice

@mohrerao now the upgrade path test is missing and my first point in #123 was not addressed at all

Removing the novice tag because this is not a novice task anymore.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

prairiedog’s picture

For what's it's worth, we were having an issue with images columns as well... #8, way back in the thread above, worked for us. (Project we're on is Drupal 8.9.7; changing the aggregation on images solved the problem after our team had spent hours.)

@manojapare - thanks.

jungle’s picture

Status: Needs work » Needs review
Issue tags: +Bug Smash Initiative

Addressing #123 based on the patch in #121.

Tagging "Bug Smash Initiative"

jungle’s picture

StatusFileSize
new28.73 KB
new8.74 KB

Sorry, forgot attaching the patch.

jungle’s picture

StatusFileSize
new28.54 KB

A patch for 9.1.x

jungle’s picture

StatusFileSize
new29.08 KB
new29.27 KB
new9.35 KB
new714 bytes

Ignore the patches in #133 and #134 please.

Trying to address #123 based on the patch in #121 again.

jungle’s picture

jibran’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/tests/src/Functional/Update/EmptyFieldGroupColumnUpdateTest.php
@@ -0,0 +1,43 @@
+ * @see views_post_update_empty_entity_field_group_column()

Are we missing this update hook?

jungle’s picture

Status: Needs work » Needs review

Thanks @jibran, It exists in #118, but got removed in #121

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

seanb’s picture

StatusFileSize
new32.53 KB

Added a patch for 9.3.x based on the latest MR.

Status: Needs review » Needs work

The last submitted patch, 143: 2815881-143-9.3.x.patch, failed testing. View results

lendude’s picture

Status: Needs work » Needs review
Issue tags: -views aggregation, -Needs issue summary update, -Needs change record
StatusFileSize
new13.49 KB
new32.3 KB

Based this of the patch in #143

  • The test was failing because a View got added to Umami that has an empty group_column. Fixed that.
  • While fixing that found out that the update hook was only tailoring for 'field' not 'entity_field', fixed that and added coverage to the update test for that.
  • As @jibran pointed out on the MR, the update itself should be much simpler if we use the power of ViewsConfigUpdater, did that, which is a lot of refactoring but looks much much cleaner now.
  • Somewhere along the way, the update test View got a value added to 'group_column' so it wasn't actually testing anything anymore. Added a 'before' set of assertions to make sure we start with broken config.
  • We are triggering a deprecation, which need a CR, so added a CR.
mkimmet’s picture

Tested patch #145 on Drupal 9.3.0 and seems to be working. Fixed the 1054 Unknown Column error I was seeing, for what it's worth.

troybthompson’s picture

Solved my problem with 9.3.9. After adding the image field, I had to go into the aggregation setting for the field and save it before the error went away.

prasanth_kp’s picture

Applied patch #145 and issue fixed

Before patch:
before

After patch:
after

klemendev’s picture

Nice, hope this gets into core soon as this is really annoying bug

klemendev’s picture

Status: Needs review » Reviewed & tested by the community
klemendev’s picture

As per #146, #147 and #148, makring RTBC.

Let's hope we get this into core asap :)

lendude’s picture

StatusFileSize
new32.31 KB

Quick reroll

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 152: 2815881-152.patch, failed testing. View results

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new445 bytes
new32.92 KB

A broken view got added in #3173180: Add UI for 'loading' html attribute to images, hopefully this fixes it again.

Status: Needs review » Needs work

The last submitted patch, 154: 2815881-154.patch, failed testing. View results

spokje’s picture

We seem to hit the PHP 8.1 change for (mb_)strtolower(NULL) being deprecated: https://3v4l.org/fAUcN.

core/modules/views/tests/fixtures/update/views.view.group_column_post_update.yml doesn't have an uuid, which leads to this deprecation error:

Drupal\Tests\views\Functional\Update\EmptyFieldGroupColumnUpdateTest::testViewsPostUpdateEmptyFieldGroupColumn
Exception: Deprecated function: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated
Drupal\Core\Config\Entity\Query\Condition->compile()() (Line: 39)

when testing against PHP 8.1.
The same test passes with (for example) PHP 7.4

spokje’s picture

StatusFileSize
new636 bytes
new32.96 KB

Unsure if we should address the whole (mb_)strtolower(NULL)) deprecation issue here, but if we add an uuid to the group_column_post_update View all seems to pass on PHP 8.1 and lower.

Also changed `Master` to `Default`.

Let's see if these changes please the TestBot Gods...

spokje’s picture

Status: Needs work » Needs review

Green Testbot (after an initial JStest failure).

Putting this on NR, not back to RTBC because of:

Unsure if we should address the whole (mb_)strtolower(NULL)) deprecation issue here, [snip]

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

super_romeo’s picture

PHP 8.1 & MySQL 8 Patch Failed to Apply on D9.4

ravi.shankar’s picture

StatusFileSize
new32.67 KB
new15.72 KB

Added reroll of patch #157 on Drupal 9.4.x.

nod_’s picture

Status: Needs review » Needs work

Thanks for the reroll! there is still a problem on the patch for the 10.1.x branch unfortunately.

spokje’s picture

Assigned: Unassigned » spokje

spokje’s picture

Assigned: spokje » Unassigned

This is as far as I can take this MR. I have no clue why those 2 test failures happen.

nod_’s picture

Thank you!

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alexdoma’s picture

StatusFileSize
new23.28 KB

fixtures files was removed here - https://www.drupal.org/project/drupal/issues/3261245#comment-14539406
i just remove it but perhaps we need to rewrite tests
re-roll for drupal 10.1.0

klemendev’s picture

Needs work or is it needs review?

alexdoma’s picture

Needs work with tests and needs review

jsutta’s picture

StatusFileSize
new19.98 KB

Rerolled the patch for Drupal 10.2.x.

joelpittet’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Needs work » Reviewed & tested by the community

Thanks for the reroll. We use this in production as it gets past the failed SQL query on aggregation

alexpott’s picture

Version: 10.2.x-dev » 11.x-dev
Status: Reviewed & tested by the community » Needs work

Patches are no longer tested by d.o - can #172 by turned into an MR against 11.x and all the patches and other MRs hidden. Thanks!

capysara made their first commit to this issue’s fork.

capysara changed the visibility of the branch 10.1.x to hidden.

capysara changed the visibility of the branch 2815881-9.1.x to hidden.

capysara changed the visibility of the branch 2815881-switching-on-aggregation to hidden.

capysara’s picture

I created a MR using the patch in #172, against d11. It still needs work because of failing tests.

lendude’s picture

Did some clean up, no idea what spellcheck is complaining about.

I think we still need an upgrade path test for this

lendude’s picture

Apparently doing a merge to resolve conflicts makes spellcheck croak....#3401988: Spell-checking job fails with "Argument list too long" when too many files are changed, so needs a rebase

tcrawford made their first commit to this issue’s fork.

tcrawford’s picture

The blocking issue #3401988 seems to be resolved and the spellcheck has passed after merging 11.x into the issue fork. However, now other tests are failing in the pipeline.

tcrawford’s picture

Status: Needs work » Needs review

The MR (!603) against 11.x is now mergeable and pipeline is now passing. Therefore, I am moving the status to 'needs review'.

pfrenssen changed the visibility of the branch 2815881-switching-on-aggregation-10.1.x to hidden.

pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for keeping up with this and making an MR against 11.x! Reviewed the latest changes and the full patch. Looking good, tests are passing. Review remarks have been addressed. Back to RTBC!

Edit: I reviewed only the 11.x branch. I closed 10.1 since it was out of date. 10.2.x is still being maintained but I did not review it.

klemendev’s picture

Great work, can't wait to have this in the release! :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Added some review comments on the MR to address. The MR also needs to be rebased or have the latest 11.x merge and conflicts resolved.

jan kellermann made their first commit to this issue’s fork.

jan kellermann’s picture

Status: Needs work » Needs review

Re-rolled against current 11.x

fernly’s picture

StatusFileSize
new49.01 KB

Stable patch of current MR state.

fernly’s picture

Patch in 193 is not applying to 11.2.x. Weirdly enough, because 11.x got merged in the MR one month ago. Hiding the patch for now.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record updates

Left some comments on the MR.

Also CR was last updated in 2021 so could use some updates probably.

fernly’s picture

StatusFileSize
new20.08 KB

The 11.x merge request is totally out of sync with the actual Drupal 11.x version. We need a backmerge.
Created a stable patch that is applicable to Drupal 11.2.3 based on the 11.x MR 6073.

joelpittet’s picture

Status: Needs work » Needs review

Addressed the MR comments and fixed a bug in this commit https://git.drupalcode.org/project/drupal/-/merge_requests/6073/diffs?co...

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

jan kellermann changed the visibility of the branch main to hidden.

jan kellermann changed the visibility of the branch 11.x to hidden.

jan kellermann changed the visibility of the branch 2815881-switching-on-aggregation-11.x to hidden.

jan kellermann changed the visibility of the branch 2815881-switching-on-aggregation-10.2.x to hidden.

jan kellermann’s picture

Patch ported for current D11 in new branch.
Just use branch https://git.drupalcode.org/issue/drupal-2815881/-/tree/2815881-switching... for current 11.3 version.

jan kellermann’s picture

Status: Needs work » Needs review
jan kellermann’s picture

StatusFileSize
new20.48 KB

Added Patch for Drupal 11.3.9

smustgrave’s picture

Status: Needs review » Needs work

Can we get test coverage for the update hook please.