Only chain #having to tagged_with query when clause is present.

This fixes issue #365 in Rails 3.0.20 by omitting the `having` part of the query when it is not present.