I'm using postgreSQL 9, but I guess the exception could raise with any PG version. I also tried the TagClouds development version and got the same error.
PDOException: SQLSTATE[42703]: Undefined column: 7 ERROR: column "count" does not exist LINE 7:
... BY td.tid, td.vid, td.name, td.description HAVING count > 0 ^:
SELECT td.tid AS tid, td.vid AS vid, td.name AS name, td.description AS description, tn.nid AS nid, COUNT(*) AS count
FROM {taxonomy_term_data} td
INNER JOIN {taxonomy_index} tn ON td.tid = tn.tid
INNER JOIN {node} n ON tn.nid = n.nid
WHERE (td.vid IN (:db_condition_placeholder_0))
GROUP BY td.tid, td.vid, td.name, td.description
HAVING count > 0
ORDER BY count DESC LIMIT 12 OFFSET 0;
Array ( [:db_condition_placeholder_0] => 2 ) in tagclouds_get_tags() (line 225 of drupal-7.10/sites/all/modules/tagclouds/tagclouds.module).
The query resulting from the db_select should be (maybe... sorry I'm not a PHP developer. Anyway it does the job)
SELECT td.tid AS tid, td.vid AS vid, td.name AS name, td.description AS description, tn.nid AS nid, COUNT(*)
FROM blog.taxonomy_term_data td
INNER JOIN blog.taxonomy_index tn ON td.tid = tn.tid
INNER JOIN blog.node n ON tn.nid = n.nid
WHERE (td.vid IN ('2'))
GROUP BY td.tid, td.vid, td.name, td.description, tn.nid HAVING COUNT(*) > 0
ORDER BY COUNT(*) DESC
LIMIT 12 OFFSET 0
PG should be smart enough to only process COUNT(*) once
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | tagclouds-Fix_PostgreSQL_error-1425844-13.patch | 1.55 KB | ben coleman |
Comments
Comment #1
MGParisi commentedNot sure how to fix this and/or test this as I don't have a setup that uses PG:(
PDO should handle this but it is not. Not sure as to why...
Comment #2
Uclio commentedYep, I guessed. I saw somewhere a post talking about counting the resulting rows after the query. Maybe could be that a solution ? I'm willing of course to test any patch of you. I'm using Tagadelic (it works with PG) currently, but I'd like more showing the tags' count. It looks better and cleaner.
Comment #3
MGParisi commentedI would love to support PG. It would be a nice option.
Comment #4
MGParisi commentedSet to Needs Work! Please submit a patch if you can get it to work:)
Comment #5
Uclio commentedUnfortunately not (I'm still using Tagadelic). Just replacing count with COUNT(*) doesn't work. This way the query completes with no errors, but the resulting weight for each tag is always 1. Likely the query should be in some way refactored, but I can't do that since I'm not in the PHP thing.
Hint: the PostgreSQL installation is pretty simple and in a Linux VM you have it almost for free ;-)
Comment #6
simonlnu commentedmaybe single quoting the 'count' in the 'AS count' part?
i.e.:
Comment #7
simonlnu commentedok, never mind that... didn't work
Comment #8
simonlnu commentedsaw something here that might help:
http://archives.postgresql.org/pgsql-sql/2001-11/msg00366.php
http://stackoverflow.com/questions/3004887/how-to-do-a-postgresql-subque...
these are what were posted to second link. i'm including them here only as an example of how to do it.
this, is what i think might work:
Comment #9
brylie commentedI am also interested in this bug. Watching.
Comment #10
daftu commentedSame issue here. Please fix.
Watching.
Comment #11
iuvanham commentedPossible fix, works for pgsql 8.4
In tagscloud.module modify as follows:
(line 222 to 234)
Comment #12
MGParisi commentedCan I get a .patch?
Comment #13
ben coleman commentedThis is a patch corresponding to the code changes in #11. This appears to work ok in PostgreSQL 9.1.
Comment #14
joseph.olstadThe patch from #13 works also in Postgres 8.4 and also works in Postgres 9.3 (tested here)
Thanks!
Comment #15
joseph.olstadThis patch works on postgres and needs to be taken upstream as we and others use postgresql with drupal.
Asking for co-maintainer priviledges.
I have various environments am able to test this against mysql and postgresql.
Comment #16
MGParisi commentedYour wish has been granted. I just dont have the time to apply pacths right now. Would love the help!
Mike
Comment #17
joseph.olstadThe patch works in either MySQL 5.1.73 or PostgresSQL 8.4 or 9.3
I don't see any reason why it wouldn't work with other versions of those and other db's as the change is on the user side of the drupal data abstraction layer.
Obviously the original code exposed some weakness in the postgres portion of the drupal database abstraction layer but the patch completely avoids that and it works.
*asking for co-maintainer access again* to commit this patch (the was a problem with my drupal.org account that seems to be resolved now (knock on wood))
Comment #19
joseph.olstadCommitted patch to the dev branch and attributed contributions to Uclio, Ben Coleman, simonlnu, iuvanham.
Thanks Uclio, Ben Coleman, simonlnu, and iuvanham.
Comment #20
MGParisi commentedThanks Joseph!
Comment #21
joseph.olstad