Does acts_as_taggable work with Oracle?


#1

I’m using acts_as_taggable just fine with my Oracle database using the
oci driver, until I try to either use the tags_count, or tagged_related.

For tags_count I can get the default hash table fine, but if I try to
provide a filter like “count > 3”, I get an error:

Content.tags_count(:count=>’>3’)

ActiveRecord::StatementInvalid: OCIError: ORA-00904: “COUNT”: invalid
identifier
: SELECT tags.id AS id, tags.name AS name, COUNT(*) AS count FROM
contents_tags,
content_table, tags WHERE contents_tags.tag_id = tags.id
AND contents_tags.content_id = content_table.content_id
GROUP BY
tags.id,tags.name HAVING count >3 ORDER BY count DESC
from
C:/newruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_re
cord/connection_adapters/abstract_adapter.rb:120:in log' from C:/newruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_re cord/connection_adapters/oracle_adapter.rb:271:inexecute’
from
C:/newruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_re
cord/connection_adapters/oracle_adapter.rb:473:in select' from C:/newruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_re cord/connection_adapters/oracle_adapter.rb:262:inselect_all’
from
C:/newruby/lib/ruby/gems/1.8/gems/acts_as_taggable-2.0.2/lib/taggab
le.rb:339:in `tags_count’
from (irb):24

This should be allowed, from the docs:

+:count+: Adds a HAVING clause to the SQL statement, where you can set
conditions for the ‘count’ column. For example: ‘> 50’

But Oracle doesn’t like the final result. Is there some special tweak
I’m supposed to make to the HAVING clause work properly?

D


#2

This may interest you:

http://www.oracle.com/technology/pub/articles/kern-rails-tagging.html