Attempting to build a view/block showing a all users that favourited a node, when viewing that node.

Error:
user warning: Unknown column 'views_bookmark_nodes_1.uid' in 'on clause' query:
SELECT DISTINCT(node.nid), users.name AS views_bookmark_nodes_1_name, views_bookmark_nodes_1.uid AS views_bookmark_nodes_1_uid FROM node node
LEFT JOIN users users ON views_bookmark_nodes_1.uid = users.uid
LEFT JOIN views_bookmark_nodes views_bookmark_nodes_1 ON node.nid = views_bookmark_nodes_1.nid AND views_bookmark_nodes_1.vbid = '1'
WHERE (node.type IN ('artist')) AND (node.nid = 6769) LIMIT 0, 10

View from GUI admin (admin/build/views)
field: Bookmark: User for Favourite Artists
argument type: Node: ID
filter: Node Type: Artist

If the 2 left join clauses were switched in the sql, it would return the result set.

Thanks
Audrey

Comments

quicksketch’s picture

Sorry it's been a while before responding. Are you still having this issue with the latest 5.x version (1.4 or higher)? If so, could you post an export of your view so that I can replicate? Thanks!

mooffie’s picture

Assigned: Unassigned » mooffie

I know of this bug. I'll provide a patch soon.

A quick solution:
Add the 'Bookmark: bookmarks' filter.

mooffie’s picture

OK. The patch for #211112, allow sort by user names solves this bug.

Explanation:

When you ask to show the username, by including the 'Bookmark: User for xyz' field, its handler kicks in. This handler pulls in the 'users' table. It JOINs this table to the 'views_bookmark_nodes' table. But... it doens't ensure the 'views_bookmark_nodes' table itself was pulled in. Unless you add the 'Bookmark: xyz' filter, this table isn't pulled in. That's why you get an error.

The patch for #211112 solves this bug because it gets rid of the handler. It lets smart Views handle everything.

But, if that patch doesn't get commited, the way to solve this bug should be to add $query->ensure_table($field['tablename']) to the views_bookmark_qhandler_username() handler.

mooffie’s picture

Priority: Normal » Critical
Status: Active » Needs review

But, if that patch doesn't get commited, the way to solve this bug should be to add $query->ensure_table($field['tablename']) to the views_bookmark_qhandler_username() handler.

I just added an alternative patch for #211112, and in it I included this on-line fix.

So I'm marking this "code needs review".

I'm also promoting this to "critial", because it's hard not to bump into this bug.

quicksketch’s picture

Status: Needs review » Fixed

With http://drupal.org/node/211112 applied, this problem is corrected also.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.