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?

CommentFileSizeAuthor
#5 view-result.png60.22 KBrob230
#5 view-setup.png46.51 KBrob230
view.txt22.51 KBi-grou

Comments

ivanklochko created an issue. See original summary.

i-grou’s picture

Issue summary: View changes
Anonymous’s picture

4 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.

tr’s picture

Version: 8.x-3.0-beta1 » 8.x-3.x-dev
Priority: Major » Normal
Issue tags: -views, -voting

"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.

rob230’s picture

StatusFileSize
new46.51 KB
new60.22 KB

I'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:

id	type	entity_type	entity_id
16	updown	paragraph	184
17	updown	paragraph	126

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:

SELECT "votingapi_vote"."id" AS "id"
FROM
{votingapi_vote} "votingapi_vote"
WHERE ("votingapi_vote"."type" IN ('updown')) AND ("votingapi_vote"."entity_type" LIKE 'paragraph' ESCAPE '\\')
LIMIT 11 OFFSET 0

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".

view setup

view result

I believe it does work for the entity type of node. The views integration is just broken for other entity types.

rob230’s picture

rob230’s picture

It 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.