Error in query for pgsql
Yoran - October 8, 2008 - 09:46
| Project: | Comment RSS |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Dave Reid |
| Status: | closed |
Description
Hello,
This version don't give any results with postgresql system.
In your query :
$SQL = 'SELECT '. $nidselector .', c.cid, c.subject, c.comment, c.timestamp, c.uid, c.name, c.format, u.name username, n.title FROM {node} n '. $joins .' INNER JOIN {comments} c ON c.nid = n.nid INNER JOIN {users} u ON c.uid = u.uid WHERE '. $where .' n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC';
You should have an 'AS' keyword between 'u.name' and 'username'
Regads.

#1
Otherwise the module works all great with pgsql?
#2
I stole a look through the code to see if anything is wrong with that query, but everything conforms to SQL-99. However, I was a little puzzled by the following:
<?php
// Add passed query parameter; plus we are looking for published comments.
$params = isset($param) ? array($param) : array();
$params[] = COMMENT_PUBLISHED;
// Use query rewriting for node level access permission support.
$comments = db_query_range(db_rewrite_sql($SQL), $params, COMMENT_PUBLISHED, 0, variable_get('feed_default_items', 10));
?>
It looks like the COMMENT_PUBLISHED is included twice in the parameters passed to db_query_range and it doesn't look like there is a need for it...
#3
Gábor Hojtsy,
Hey! This was reported on October 8 and not checked in... Why not?! I fixed that bug too and I downloaded the module only a few days ago (like less than 7) and I should have gotten the fixed version! (as I took the -dev module)
Would you mind quickly fixing this bug? The 'AS' will work just fine in MySQL and Oracle.
The rest seems to work just fine with PostgreSQL.
Thank you.
Alexis Wilke
#4
Patch attached for the missing AS.
#5
Looks good to me. 8-)
Thank you.
Alexis Wilke
#6
I just came across this again as well. Patch looks good.
SR
#7
Committed to 6.x-2.x and 5.x-2.x. Thanks!
#8
Automatically closed -- issue fixed for 2 weeks with no activity.