Hi,
This module doesn't work on PostgreSQL 8.4 as per my test.
I checked the code, everything seemed to be fine, except for db_rewrite_sql. I have not meddled with the core or something else, but
I changed this line (line no. 238) in your code:
$sql = db_rewrite_sql($sql)
to
$sql = db_rewrite_sql($sql, null, null, array('distinct' => false))
and it worked. This seems to be more of an issue with db_rewrite_sql, but no other modules complain to this. Very funny.
The SQL generated before the line was altered is:
SELECT DISTINCT n.nid, n.title, COUNT(n.nid) AS ncount FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid 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 = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid'))) AND ((n.moderate != 1)) AND ( tn.tid IN ('%s','%s') AND n.type IN ('%s','%s') AND n.nid != %d AND n.status = 1 AND n.moderate = 0 AND (n.language = '' OR n.language = '%s') )GROUP BY n.nid, n.title, n.created ORDER BY ncount ASC, n.created DESC LIMIT %d
and after the alteration is:
SELECT n.nid, n.title, COUNT(n.nid) AS ncount FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('%s','%s','%s','%s','%s','%s') AND n.type IN ('%s','%s') AND n.nid != %d AND n.status = 1 AND n.moderate = 0 AND (n.language = '' OR n.language = '%s') GROUP BY n.nid, n.title, n.created ORDER BY ncount ASC, n.created DESC LIMIT %d
The DISTINCT clause is creating trouble in PostgreSQL.
Any ideas ? or this a core bug ?
Comments
Comment #1
rmiddle CreditAttribution: rmiddle commentedI need to double check my SQL but if I had to guess I would bet the issue is with the content access module not similiarterm module. But it is a simple enough change to the code I will look at putting that in the next version of the code.
Thanks
Robert
Comment #2
nileshgr CreditAttribution: nileshgr commentedYeah one more point I forgot to mention is that, initially the module was working, but after installation of content_access, I had to make this alteration.
Comment #3
rmiddle CreditAttribution: rmiddle commentedPatch never made it in and the 2.x branch is a complete rewrite.
Thanks
Robert