SQL bug in acts_as_taggable


#1

Hi,

excuse me if this is off-topic and feel free to ingore it in case.

I’m using acts_as_taggable (the gem version) and found what to me
looks like a bug in this code from the method tags_count:

       sql = "SELECT #{t}.#{t_pk} AS id, #{t}.name AS name, COUNT

(*) AS count
FROM #{jt}, #{o}, #{t} WHERE #{jt}.#{t_fk} = #{t}.#{t_pk}
AND #{jt}.#{o_fk} = #{o}.#{o_pk}"
sql << " AND #{sanitize_sql(options[:conditions])}" if
options[:condit
ions]
sql << " GROUP BY #{t}.name"

My database (PostgreSQL 8) laments that the ‘tags.id’ column should
be in the “GROUP BY” clause, which seems reasonable to me. The last
line should be:

       sql << " GROUP BY #{t}.name, #{t}.#{t_pk}"

It seems strange, however, that I’m the only one to be bitten by this
bug, so I wonder if maybe some other database (MySQL?) lets this pass.

Ugo


Ugo C.
Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Evil or Not?: http://evilornot.info/
Company: http://www.sourcesense.com/


#2

yes, mysql would handle this in most of the cases

good discovery for other databases though


#3

Il giorno 21/mar/06, alle ore 18:43, Emin H. ha scritto:

yes, mysql would handle this in most of the cases

good discovery for other databases though

Unfortunately there’s a bug open for a similar problem <http://
rubyforge.org/tracker/index.php?
func=detail&aid=2482&group_id=923&atid=3629> since last september, so
I don’t think it’s going to get fixed soon.

Ugo