Views doesn't join the right table for relationships with long table names

Created on 13 February 2016, over 8 years ago
Updated 25 August 2023, 10 months ago

Problem/Motivation

I juste spent a few hours trying to figure out what was wrong but without success.

Given I have a field_interpretation_target on a field_collection_item, the base table of this field is not field_collection_item__field_interpretation_target but something like field_collection_item__8283872305 (see \Drupal\Core\Entity\Sql\DefaultTableMapping::getDedicatedDataTableName).

The thing is that, for some reason, Views keeps using the default table name so it leads to a fatal error:

        field_interpretation_target:
          id: field_interpretation_target
          table: field_collection_item__field_interpretation_target
          field: field_interpretation_target
          relationship: field_interpretations_value
          group_type: group
          admin_label: Target
          required: true
          plugin_id: standard

Steps to reproduce:

  1. Install Drupal and Field Collection (dev version)
  2. Add a field on your article content type with a long machine name (field_very_very_very_long_name)
  3. Create a page view of articles
  4. Add a relationship on the field
  5. Save then show the view

Expected result: empty set of rows
Current result: fatal error (table does not exist)

Proposed resolution

After my investigation I found that something was happening in \Drupal\views\Plugin\views\relationship\RelationshipPluginBase::query probably around $def['left_table'] = $this->tableAlias;

Remaining tasks

Figure out what's happening
Write a test to demonstrate the issue
Fix the problem
Review
Commit
Enjoy

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Closed: outdated

Version

9.5

Component
ViewsΒ  β†’

Last updated 1 day ago

Created by

πŸ‡«πŸ‡·France DuaelFr Montpellier, France

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

Sign in to follow issues

Comments & Activities

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Since there hasn't been a follow up or movement going to close for now.

    If still a valid bug please reopen verifying steps to reproduce.

    Thanks all

Production build 0.69.0 2024