I've created a view to display recent votes for media entities but it shows empty entity fields (id, title and other). See view export attached.
The reason is bad query:
SELECT votingapi_vote.timestamp AS votingapi_vote_timestamp, votingapi_vote.id AS id, node_field_data_votingapi_vote.nid AS node_field_data_votingapi_vote_nid
FROM
{votingapi_vote} votingapi_vote
LEFT JOIN {node_field_data} node_field_data_votingapi_vote ON votingapi_vote.entity_id = node_field_data_votingapi_vote.nid
ORDER BY votingapi_vote_timestamp DESC
LIMIT 51 OFFSET 0
Why `node_field_data` table is used? Here we have media type entity not node.
Any ideas how to fix it?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | view-result.png | 60.22 KB | rob230 |
| #5 | view-setup.png | 46.51 KB | rob230 |
| view.txt | 22.51 KB | i-grou |
Comments
Comment #2
i-grou commentedComment #3
Anonymous (not verified) commented4 years later, the same problem still persists. Indicates that an unrelated node was voted on when you voted for a media.
If the node to which the media is connected appears to be voted, we will analyze it as well. But it seems like another unrelated node has been voted in the views table even though the media is voted.
Comment #4
tr commented"4 years later, the same problem still persists"
And in those 4 years, there have been exactly zero other reports of this problem. Likewise, there are no details that we can use to try to reproduce the problem, no tests written that demonstrate the problem, and no patches contributed that provide a fix.
@jaydenpearly: If you want to help out, you can detail the steps that must be followed - on a clean site - in order to reproduce this problem.
Comment #5
rob230 commentedI'm seeing something similar (to the issue title anyway).
I have added a rate widget to paragraph entities, and voted.
You can see here that I have 2 votes, with entity IDs:
I have added the "Vote: Voted entity" field with "Entity ID" formatter. And the result is blank. If I show the SQL in Views, it is doing this:
No attempt has been made to fetch the entity ID column. But maybe it only needs the vote ID and uses formatters to fetch other fields, but these are not working for "Voted entity".
I believe it does work for the entity type of node. The views integration is just broken for other entity types.
Comment #6
rob230 commentedI wonder could what I've discovered be related to #2925546: Views integration (among other things) broken when voting on non-node entities.
Comment #7
rob230 commentedIt looks like the patches on #2988057: Voting API REST POST (create with REST) doesn't work, validation error, when referenced entity other than node do make this field work, so I can at least see the paragraph ID.
Unfortunately, there are no relationships that can be made from it (e.g. to the paragraph). There is just a "Content" ("The ID from the voted entity") relationship, which joins to node_field_data causing there to be no results.