Using Views 5.x-1.5 with Drupal 5.1:

When adding a new Calendar view, I get an error when trying to add in http://mysite/?q=admin/build/views/edit/1 a filter of the following type:
"Book: parent node"

The error is:

user warning: Unknown column 'book.vid' in 'on clause' query: SELECT DISTINCT parent FROM prefix_book INNER JOIN prefix_node n ON book.vid = n.vid ORDER BY parent in /var/htdocs/drupal50/includes/database.mysqli.inc on line 151.

All my database tables start with 'prefix_'

It looks like the error is on line 131 of modules/views_book.inc , which reads:

  $result = db_query("SELECT DISTINCT parent FROM {book} INNER JOIN {node} n ON book.vid = n.vid ORDER BY parent");

[ON book.vid =] should probably read [ON {book}.vid =] to accept table prefixing. Making this change solves the problem for me.

CommentFileSizeAuthor
#4 views-filter-book-parent_0.patch682 bytesAnonymous (not verified)
#1 views-filter-book-parent.patch685 bytesAnonymous (not verified)

Comments

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new685 bytes

If it is easier to fix this problem by providing a patch - here it is ;-)

yched’s picture

I think the usual syntax is rather to add an alias to the table :
SELECT DISTINCT parent FROM {book} b INNER JOIN {node} n ON b.vid = n.vid

neclimdul’s picture

Status: Needs review » Needs work

yched is correct, this should be aliased.

Anonymous’s picture

StatusFileSize
new682 bytes

Thanks for the hint/remark ... I updated the patch (it's my first one ;-))

merlinofchaos’s picture

Status: Needs work » Fixed

Committed. Thanks for the patch!

Anonymous’s picture

Status: Fixed » Closed (fixed)