tmiyamon / acts-as-taggable-array-on

A simple and high performance tagging gem for Rails using PostgreSQL array.
MIT License
125 stars 26 forks source link

Fix for single table inheritance models #39

Closed cbillen closed 2 years ago

cbillen commented 2 years ago

If you have a single table inheritance, e.g

class Post < Article end

and article has taggable_array :tags

Calling Post.all_tags will result in an error because the where clause filtering by the submodel type gets repeated outside the subquery

This fix ensures that our query is unscoped outside the subquery

skatkov commented 2 years ago

@cbillen This is awesome work, I never got the time to address this issue - but you did it. Any chance you can add some test for this as well?

cbillen commented 2 years ago

@skatkov no worries, it actually failed some tests initially but by specifying unscope(where: :type) it can handle your other test cases and I added some new STI models. Let me know if it is to your satisfaction

skatkov commented 2 years ago

@cbillen sorry, only now found time to look into this.

Do you think this would require a major bump to gem version?

cbillen commented 2 years ago

Since it's a fix and not a new feature nor does it change the API, I would just make it a 0.6.1 release or something like that, unless you have other changes

skatkov commented 2 years ago

Looks great!