Add cardinality_unlimited taxonomy reference to custom entity Okay, so I'm getting an error that I think may be a Views bug, but I don't have enough knowledge about Views &amp; SQL right now to be sure about that.

Here's the hook I'm using to install the new field into the poll entity, using drush entity-updates:

/**
 * Implements hook_entity_base_field_info().
 */
function mymodule_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type-&gt;id() === 'poll') {
    $fields['cat'] = BaseFieldDefinition::create('entity_reference')
      -&gt;setLabel(t('Category'))
      -&gt;setDescription(t('Category of poll'))
      -&gt;setSetting('target_type', 'taxonomy_term')
      -&gt;setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
      -&gt;setDisplayOptions('form', array(
        'type' =&gt; 'entity_reference_autocomplete',
        'weight' =&gt; -10,
        'settings' =&gt; array(
          'match_operator' =&gt; 'CONTAINS',
          'size' =&gt; '60',
          'autocomplete_type' =&gt; 'tags',
          'placeholder' =&gt; '',
        ),
      ))
      -&gt;setTranslatable(TRUE);
    return $fields;
  }
}


Then, I make a view that would like to use this taxonomy term as a Contextual Filter.  I want to use the taxonomy term name rather than the ID, so I need to add a relationship.  I add relationship in the view and look for the Taxonomy Term relationship that has my description, "Category of poll" and select it.  The view complains about a SQL error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'poll__cat.cat' in 'on clause': SELECT poll_field_data.id AS id, taxonomy_term_field_data_poll__cat.tid AS taxonomy_term_field_data_poll__cat_tid FROM {poll_field_data} poll_field_data LEFT JOIN {poll__cat} poll__cat ON poll_field_data.id = poll__cat.entity_id AND poll__cat.deleted = :views_join_condition_0 LEFT JOIN {taxonomy_term_field_data} taxonomy_term_field_data_poll__cat ON poll__cat.cat = taxonomy_term_field_data_poll__cat.tid LIMIT 5 OFFSET 0; Array ( [:views_join_condition_0] =&gt; 0 )

The reason for the error in the above query is that the poll__cat.cat column does not exist, but it rather SHOULD be poll__cat.cat_target_id.

My question is: is this a views bug or a bug with the way I'm adding the field to the poll entity, and if it is a views bug:


How do I debug it? Where does views set the column name it's looking for?
Is there a hook I can use to change it,  and/or should I submit this odd case to the views project?


EDIT: I'm trying to use hook_views_query_alter and hook_views_pre_execute to try and modify the broken query to do what I want it to do, but it is incredibly frustrating, because all of the things are protected, and it is very inconvenient to access anything, considering the purpose of these hooks is to modify data.  I'm trying to look through the functions for ViewExecutable and the views Sql class, but I don't see anything that will help me change the column to what it should be!  Anyone who can help in any way, I will be so grateful.

Edit 2: It seems like this guy: Views doesn&#39;t like multiple entity references in my entity has had a similar problem.  I feel like this is a bug somewhere, or at the very least an issue with CARDINALITY_UNLIMITED being confusing to implement with entity references.
This is the best solution I have been able to come up with so far.  Answers are still welcome, because I still don't know:


Why this is happening, is it a views bug?
Could I have created the field in a way that using a hook to alter the query is not necessary?


What I ended up doing was using hook_views_pre_execute(Drupal\views\ViewExecutable $view) to get the query out of $view-&gt;build_info['query']-&gt;getTables() and then manually change the condition on my join table to use the correct column, which was not poll__cat.cat but rather poll__cat.cat_target_id.