<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -41,7 +41,7 @@ class Tag &lt; ActiveRecord::Base
     if taggable_type
       conditions = sanitize_sql([&quot;taggable_type = ?&quot;, taggable_type])
       conditions += sanitize_sql([&quot; AND #{Tagging.table_name}.user_id = ?&quot;, user.id]) if user
-      with_scope(:find =&gt; {:select =&gt; 'distinct *', :joins =&gt; &quot;left outer join #{Tagging.table_name} on #{Tagging.table_name}.tag_id = #{Tag.table_name}.id&quot;, :conditions =&gt; conditions, :group =&gt; &quot;name&quot;}) { yield }
+      with_scope(:find =&gt; {:select =&gt; &quot;distinct #{Tag.table_name}.*&quot;, :joins =&gt; &quot;left outer join #{Tagging.table_name} on #{Tagging.table_name}.tag_id = #{Tag.table_name}.id&quot;, :conditions =&gt; conditions, :group =&gt; &quot;name&quot;}) { yield }
     else
       yield
     end</diff>
      <filename>lib/tag.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a22b9b9c8a1bfa3dbc5139a6a8dc1bfb37edc526</id>
    </parent>
  </parents>
  <author>
    <name>Bodaniel Jeanes</name>
    <email>me@bjeanes.com</email>
  </author>
  <url>http://github.com/bjeanes/acts_as_taggable_redux/commit/39bc86abdfeea137362065d9f84f9959889371bf</url>
  <id>39bc86abdfeea137362065d9f84f9959889371bf</id>
  <committed-date>2009-06-12T07:22:32-07:00</committed-date>
  <authored-date>2009-06-12T07:22:32-07:00</authored-date>
  <message>Fixed major bug in Tag.with_type_scope

Because we are doing a lot of joins and selecting all columns, ActiveRecord was using the ID from one of the other tables in some cases (at least on SQLite). You can see that in the example below it is using the ID from Tagging.

e.g. (before fix then after)

SQL

$ script/dbconsole
sqlite&gt; SELECT distinct * FROM &quot;tags&quot; left outer join taggings on taggings.tag_id = tags.id WHERE (&quot;tags&quot;.&quot;id&quot; = 4) AND (taggable_type = 'Message') GROUP BY name ORDER BY name ASC;
4|wtf|1|5|4|9|Message|
sqlite&gt; SELECT distinct tags.* FROM &quot;tags&quot; left outer join taggings on taggings.tag_id = tags.id WHERE (&quot;tags&quot;.&quot;id&quot; = 4) AND (taggable_type = 'Message') GROUP BY name ORDER BY name ASC;
4|wtf|1

ActiveRecord

$ script/console
&gt;&gt; # BEFORE
&gt;&gt; Tag.with_type_scope('Comment') do
?&gt;   Tag.find(4)
&gt;&gt; end
=&gt; #&lt;Tag id: 5, name: &quot;wtf&quot;, taggings_count: 1&gt;
&gt;&gt;
?&gt; #AFTER
&gt;&gt; Tag.with_type_scope('Comment') do
?&gt;   Tag.find(4)
&gt;&gt; end
=&gt; #&lt;Tag id: 4, name: &quot;wtf&quot;, taggings_count: 1&gt;

&gt;&gt; Tagging.find(5)
=&gt; #&lt;Tagging id: 5, tag_id: 4, taggable_id: 9, taggable_type: &quot;Message&quot;, user_id: nil&gt;</message>
  <tree>573ce9157cdbdf2a4bb60557c4fa909ee268b855</tree>
  <committer>
    <name>Bodaniel Jeanes</name>
    <email>me@bjeanes.com</email>
  </committer>
</commit>
