Closed cbillen closed 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?
@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
@cbillen sorry, only now found time to look into this.
Do you think this would require a major bump to gem version?
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
Looks great!
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