when making a view with views_bookmark, get an sql error

aufumy - December 14, 2007 - 00:45
Project:Views Bookmark
Version:HEAD
Component:Code
Category:bug report
Priority:critical
Assigned:mooffie
Status:closed
Description

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

#1

quicksketch - January 17, 2008 - 05:31

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!

#2

mooffie - January 17, 2008 - 12:32
Assigned to:Anonymous» mooffie

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

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

#3

mooffie - January 18, 2008 - 11:51

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.

#4

mooffie - January 20, 2008 - 09:08
Priority:normal» critical
Status:active» patch (code 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.

#5

quicksketch - January 25, 2008 - 21:06
Status:patch (code needs review)» fixed

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

#6

Anonymous (not verified) - February 8, 2008 - 21:11
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.