SQL Error when You hit the tracker folder after selecting my account after upgrading to mySQL 5.0.19

jmercier - April 12, 2006 - 15:30
Project:Extended Tracker
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

The error you will recive would be similar to

user error: Unknown column 'n.nid' in 'on clause'
query: SELECT COUNT(n.nid) FROM node n, term_node t LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = t.nid AND n.status = 1 AND (n.uid = 248 OR c.uid = 248) in \includes\database.mysql.inc on line 66.

Which stems from the line 189 of xtracker.module which is
$sql_count = 'SELECT COUNT(n.nid) FROM {node} n, {term_node} t LEFT JOIN {comments} c ON n.nid = c.nid WHERE n.nid = t.nid AND n.status = 1 ' . $sql_where;

It seems that when upgrading from 4.1.x to 5.0.1x the position of the tables in the FROM statement for a LEFT JOIN is significant. By switching the code "FROM {node} n, {term_node} t LEFT JOIN" to "FROM {term_node} t,{node} n LEFT JOIN" the resultant SQL call will operate as expected for both release 4 and 5 of mySQL versions of the code.

Here is the affected code with the changes in place.

$sql_count = 'SELECT COUNT(n.nid) FROM {term_node} t,{node} n LEFT JOIN {comments} c ON n.nid = c.nid WHERE n.nid = t.nid AND n.status = 1 ' . $sql_where;

#1

jayesh - July 16, 2006 - 13:37

Still code is not working.

It shows no data to be displayed.

What to do ?

#2

uncue - July 25, 2006 - 20:59

Fresh install of 4.7.2 on Ubuntu 6.06 Server LTS mySQL 5.0.19

same problem. I'm disabling the module. If you could fix it, that would be great.

Uncue

#3

uncue - July 25, 2006 - 21:07

My apologies. The SQL statement does resolve my problem. I'm not sure if it causes errors in SQL 4, but if not this fix should be added to the module.

thanks again!

Uncue

#4

uncue - July 25, 2006 - 21:08

Also statement in question is on line 198 not 189.

#5

Csabo - December 15, 2006 - 15:23

I had the same problem after installing xtracker using same MySQL. Applied this fix, it works fine now. Thanks for the patch! (It should be fixed in the module though.)

 
 

Drupal is a registered trademark of Dries Buytaert.