I'm getting the below, in a View of a custom entity with a entity reference field with a taxonomy term (field definition below).
The strange think is that this error doesn't appear for the admin user but appears for a user with less privileges. Testing I found that the permission which causes the views works or not is "Adminster Tac Lite"
This is the error:
Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Report[report]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'stat_entity.tid' in 'where clause': SELECT stat_entity.front_user AS stat_entity_front_user, stat_entity.metric AS stat_entity_metric, stat_entity.id AS id, taxonomy_term_field_data_stat_entity.tid AS taxonomy_term_field_data_stat_entity_tid FROM {stat_entity} stat_entity INNER JOIN {taxonomy_term_field_data} taxonomy_term_field_data_stat_entity ON stat_entity.metric = taxonomy_term_field_data_stat_entity.tid LEFT OUTER JOIN {taxonomy_term_field_data} tac_td ON stat_entity.tid = tac_td.tid WHERE ( (stat_entity.tid IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4)) OR (tac_td.vid NOT IN (:db_condition_placeholder_5)) ) ORDER BY stat_entity_front_user ASC, stat_entity_metric ASC LIMIT 51 OFFSET 0; Array ( [:db_condition_placeholder_0] => 0 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => 1 [:db_condition_placeholder_3] => 2 [:db_condition_placeholder_4] => 3 [:db_condition_placeholder_5] => status ) in Drupal\views\Plugin\views\query\Sql->execute() (line 1488 of core/modules/views/src/Plugin/views/query/Sql.php).
This is the field definition:
$fields['metric'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Metric'))
->setDescription(t('Metric taxonomy that is the Log Type'))
->setRevisionable(TRUE)
->setSetting('target_type', 'taxonomy_term')
->setSetting('handler', 'default:taxonomy_term')
->setSetting('handler_settings', array(
'target_bundles' => array(
'logs_type' => 'logs_type',
)
)
)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'entity_reference_label',
'weight' => 4,
))
->setDisplayOptions('form', array(
'weight' => 4,
'type' => 'options_select',
))
->setRequired(true)
->setTranslatable(false)
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
Comment | File | Size | Author |
---|---|---|---|
#6 | primary_table-2850750-6.patch | 507 bytes | Tomazetti |
views.view_.report.yml | 24 KB | ferriol |
Comments
Comment #2
cocorodeo CreditAttribution: cocorodeo commentedHello,
I confirm that I'm having the exact same issue with the same configuration : a custom view with etity reference field to taxonomy_term.
And the problem occurs only for anonymous user (in my case only admin can administer tac_lite) ...
Is this issue fixed in dev version ?
[UPDATE]
I've installed the dev version and the problem still occurs ... the generated sql request is wrong when the view has entity reference to taxonomy term ...tac_lite adds aINNER JOIN
to a non existing table ex :"taxonomy_term_field_data_node__field_theme
" where "_field_theme
" is actually a node field table ex "node_field_theme
" .I'm still investigating ... :(
[UPDATE]
The table of the join is not in cause, this is the join column criteria which is wrong.
Ex request generated :
The column
node_field_data.tid
in theLEFT OUTER JOIN
is wrong, it does not exist.The column join should be
node__field_theme.field_theme_target_id
In file tac_lite.module, at line 246, there is a comment :
I think the question is good ;) and the test may not be sufficient ... This is where the
LEFT OUTER JOIN
is added I'm still on th case ...Comment #3
cocorodeo CreditAttribution: cocorodeo commentedI think my previous comments are related to issue #1442418
Comment #4
Tomazetti CreditAttribution: Tomazetti commentedI made a patch to try to fix this problem.
Comment #5
Tomazetti CreditAttribution: Tomazetti commentedComment #6
Tomazetti CreditAttribution: Tomazetti commentedForgot to add
taxonomy_term_data
in the previous patch.Comment #7
Tomazetti CreditAttribution: Tomazetti commentedComment #8
mngates CreditAttribution: mngates commentedThank you, @Tomazetti. I applied your patch in #6 and it solved white-screening and SQL errors. Works great for me.
Comment #9
abu-zakham CreditAttribution: abu-zakham at Vardot commentedThank you, @Tomazetti.
Comment #10
abu-zakham CreditAttribution: abu-zakham at Vardot commentedComment #11
stevecowie CreditAttribution: stevecowie commentedI've also hit same problem and confirm that @Tomazetti patch at #6 fixes it.
Comment #12
slefevre@ccad.edu CreditAttribution: slefevre@ccad.edu commentedRTBC, we've been running patch #6 for months.
Comment #13
nicholasThompsonConfirmed - this fixes the error for us too
Comment #15
mukila CreditAttribution: mukila commentedCommited in dev branch