6.0.0-alpha14
7/3/25

[#10633] DB query with output name in HAVING clause
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

History
10/15/2011 12:00:02 AM Michael Rubinsky Comment #3 Reply to this comment
FYI Content 1.0.3 was just released which contains this, and other, fixes.
10/14/2011 06:23:13 PM Michael Rubinsky Comment #2
State ⇒ Resolved
Reply to this comment
This is already fixed in git.
10/12/2011 10:22:37 AM Jan Schneider Assigned to Michael Rubinsky
Version ⇒ 1.0.2
State ⇒ Assigned
 
10/11/2011 09:05:41 PM thpo+horde (at) dotrc (dot) de Comment #1
Priority ⇒ 1. Low
Type ⇒ Bug
Summary ⇒ DB query with output name in HAVING clause
Queue ⇒ Content
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
Reply to this comment
Note: this is actually Content 1.0.2 (but I could not select this for 
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"]

Saved Queries