TranslationLanguageRenderer adds langcode field to query even if corresponding value field is not added

Created on 26 May 2023, almost 2 years ago

Problem/Motivation

We noticed some duplicates in one of our views.
It's a view that returns fields from relationships and uses grouping. The problem is that the view adds langcode columns to the GROUP BY even for fields that we don't want to add to the GROUP BY.

Steps to reproduce

I attached the YAML of a very simple view that reproduces the problem. It contains a relationship to an user and displays the user name.

If we set group_column: value on the user name field, it will generate this GROUP BY:

GROUP BY "users_field_data_node_field_data_name", "users_field_data_node_field_data_langcode"

This is fine and expected.

However, if we set group_column: entity_id, it generates this GROUP BY:

GROUP BY "users_field_data_node_field_data_langcode"

This is an unexpected behavior because I expected the users_field_data_node_field_data table to not be used in the GROUP BY at all.
I think it should only add the langcode column when another column of this table is added.

Proposed resolution

TranslationLanguageRenderer::query() should probably only be called when the corresponding EntityField is actually added to the query.

πŸ› Bug report
Status

Active

Version

9.5

Component
ViewsΒ  β†’

Last updated about 4 hours ago

Created by

πŸ‡«πŸ‡·France prudloff Lille

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024