Hi,
6.x-2.0-beta1 had a SQL query which doesn't work on PostgreSQL.
I have made a patch for it.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 2010-04-04_761276_comment_subject_pgsql_D7[unix].patch | 1.51 KB | arhak |
| #12 | comment-subject-pgsql.patch | 616 bytes | nileshgr |
| #4 | comment-subject-pgsql.patch | 635 bytes | nileshgr |
| comment-subject-pgsql.patch | 647 bytes | nileshgr |
Comments
Comment #1
arhak commentedthanks
Comment #2
arhak commentedit seems that at the time I addressed that query as if comments had revisions (like nodes do),
that's why the group by cid,nid,
but cid is primary key, therefore that group by was nonsense
BUT, what version are we talking about?
I can't find that on my repo,
the proposed fix is correct, but it is how it currently is
I just re-downloaded 6.x-2.0-beta1, 6.x-2.x-dev, 7.x-2.0-alpha1, and it is that way on those versions
Comment #3
nileshgr commentedPostgreSQL follows SQL Standards strictly. Hence you cannot have a 'WHERE' in a select statement which has an aggregate function.
Download 6.x-2.0-beta1, open comment_subject.token.inc and see line 63.
I had this version on my site, and found the errors from php and pg_query in the error log.
Wait a minute. I think the diff arguments were misplaced. I will upload another patch :(
Comment #4
nileshgr commentedComment #5
arhak commentedah... is the other way around
in that case, would be Postgre ok having this:
you see, it is difficult to read the proposed Group By cid,nid when cid is primary key and therefore unique
also, a reference to Postgree documentation would be ideal for a comment above that query
to know later why it was changed to a groupby-having instead of a simple where
Comment #6
nileshgr commentedI don't have any reference as of now, but I am sure about it. I will update if I get some reference. MySQL doesn't follow SQL standards strictly so a WHERE may work with an aggregate function. But PostgreSQL is exactly opposite to MySQL in this aspect.
If you alter the code, so that it looks like this:
it works. I've tested it. And I think we need only the count of comments irrespective of cid.
Comment #7
arhak commentedcould you please, try the following
Comment #8
arhak commentedno, only the preceding ones
the restriction and ORDER BY are needed
Comment #9
nileshgr commentedYeah this works. It provides the count of comments per node. (PS: Only one row).
It works even with HAVING instead of WHERE, but the order matters.
WHERE works if placed before GROUP BY, opposite for HAVING..
A new finding:
But if you add ORDER BY clause, it won't.
Comment #10
arhak commentedthen #5 would do?
Comment #11
arhak commentedno, #9 is fine, don't need the order by, just the cid < %d
thanks for your contrib
Comment #12
nileshgr commentedHere's a patch incase anyone needs it :)
Comment #13
arhak commentedcommitted to 6.x-2.x
Comment #14
arhak commentedthe same would be needed for 7.x-2.x
Comment #15
arhak commentedattached path for 7.x-2.x