Summary | DB query with output name in HAVING clause |
Queue | Content |
Queue Version | 1.0.2 |
Type | Bug |
State | Resolved |
Priority | 1. Low |
Owners | mrubinsk (at) horde (dot) org |
Requester | thpo+horde (at) dotrc (dot) de |
Created | 10/11/2011 (5014 days ago) |
Due | |
Updated | 10/15/2011 (5010 days ago) |
Assigned | 10/12/2011 (5013 days ago) |
Resolved | 10/14/2011 (5011 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
State ⇒ Resolved
Version ⇒ 1.0.2
State ⇒ Assigned
Priority ⇒ 1. Low
Type ⇒ Bug
Summary ⇒ DB query with output name in HAVING clause
Queue ⇒ Content
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
the ticket.
In function getSimilarObjects the HAVING clause uses the output name
of a selected column. But according to the PostgreSQL doku, HAVING
operates on the rows created by GROUP BY and thus can not use the
output name.
As a result I get a fatal error with PostgreSQL:
2011-10-11T22:59:10+02:00 ERR: HORDE [ansel] SQL QUERY FAILED:
SQLSTATE[42703]: Undefined column: 7 ERROR: column "num_common_tags"
does not exist
LINE 1: ...ct_id <> 2285 GROUP BY objects.object_name HAVING num_common...
^
SELECT objects.object_name, COUNT(matches.object_id) AS
num_common_tags FROM "rampage_tagged" matches INNER JOIN
"rampage_tags" tags ON (tags.tag_id = matches.tag_id) INNER JOIN
"rampage_users" users ON users.user_id = matches.user_id AND
users.user_name = 'thpo' INNER JOIN "rampage_objects" objects ON
objects.object_id = matches.object_id INNER JOIN
"rampage_types" types
ON types.type_id=objects.type_id AND types.type_name = 'image' WHERE
tags.tag_id IN (7) AND matches.object_id <> 2285 GROUP BY
objects.object_name HAVING num_common_tags >= 1 ORDER BY
num_common_tags DESC LIMIT 10 [pid 29125 on line 812 of
"/usr/share/php/Horde/Db/Adapter/Base.php"]
2011-10-11T22:59:10+02:00 EMERG: HORDE [ansel] SQLSTATE[42703]:
Undefined column: 7 ERROR: column "num_common_tags" does not exist
LINE 1: ...ct_id <> 2285 GROUP BY objects.object_name HAVING num_common...
^ [pid
29125 on line 393 of "/srv/horde4/ansel/lib/Tagger.php"]