I get this error/warning when trying to add a book page to a parent book page:

user warning: Column 'nid' in field list is ambiguous query: SELECT COUNT(nid) FROM book LEFT JOIN i18n_node i18n ON n.nid = i18n.nid WHERE (i18n.language ='en' OR i18n.language ='' OR i18n.language IS NULL) AND ( nid = 1040) in /home/dixingto/public_html/cpj/includes/database.mysqli.inc on line 154.

What happens next is the page is added - not as a child page though, but as another parent page.

Comments

mkrakowiak’s picture

After I disabled Hierarchical Select Book, everything seems to be OK. So, it looks like there's a bug in the HS.

mkrakowiak’s picture

Project: Internationalization » Hierarchical Select
Version: 5.x-2.4 » 5.x-3.0-rc2
Vuds’s picture

Version: 5.x-3.0-rc2 » 5.x-3.x-dev

I've got that too (and another, that appears it is not related so I'll create a new issue), but in my case the weird combination is with OG Access Control module.

user warning: Column 'nid' in field list is ambiguous query: SELECT COUNT(nid) FROM book INNER JOIN node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'og_public') OR (na.gid = 47 AND na.realm = 'og_admin'))) AND ( nid = 164) in /var/www/html/includes/database.mysql.inc on line 172.

I am not able even to select a parent after receive the warning above (it appears when carrying the page in edit mode).

Disabling one or another, makes it functional again.

wim leers’s picture

Project: Hierarchical Select » Internationalization

Can't be HS. HS doesn't affect any queries. If there'd be a bug, you'd notice while/after submitting a form.

Vuds’s picture

Project: Internationalization » Hierarchical Select

But look Wim, I have the same problem and the module that is incompatible is *different* from mkrakowiak (me = OG Access Control, him = il8n).

Anyway, HS works on node load too. Considering that HS Book is related with nodes (= nid) and not taxonomy, and our errors are coming from a nid query, there is a real possibility to have this issue really.

wim leers’s picture

Status: Active » Closed (won't fix)

No.

HS doesn't alter any queries. The end.

Move to wherever applicable but I'm certain this is not an HS issue.

Vuds’s picture

Status: Closed (won't fix) » Needs review

Yes, this is your problem:

hs_book.module
line 115

You use:
$count = db_result(db_query(db_rewrite_sql("SELECT COUNT(nid) FROM {book} WHERE nid = %d"), $item));

when you should use

$count = db_result(db_query(db_rewrite_sql("SELECT COUNT(n.nid) FROM {book} n WHERE n.nid = %d"), $item));

since you had been smart enough to think in preventing issues with access controls modules, but forgot that it necessary would need to do table joins in the query to do that.

Now it works perfectly.

Thanks for attention.

mkrakowiak’s picture

Vuds thanks for the fix, Wim thanks for this great module.

wim leers’s picture

Hah! Right. My point still stands: HS doesn't alter any queries. I just forgot that I wrote my own queries (heavily inspired by core's of course) for hs_menu and hs_book.

Will be fixed tomorrow, now it's 2 AM and an entire day of beach volleybal, so I'm exhausted!

wim leers’s picture

Title: Adding a book page to a parent fails » hs_book_hierarchical_select_valid_item()'s query fails when a module is installed that applies db_rewrite_sql() on it
Component: Code » Coke - Book
Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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