mbleigh / acts-as-taggable-on

A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.
http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
MIT License
4.97k stars 1.2k forks source link

avoid select(all_fields) in any tag query to fix error when use as subquery #1049

Open kikyous opened 3 years ago

kikyous commented 2 years ago

@enomotodev @donquxiote someone can review this pr?

donquxiote commented 2 years ago

@kikyous I'm not a maintainer, you probably want @seuros

seuros commented 2 years ago

@kikyous the PR look fine, but can you add a test case ?

kikyous commented 2 years ago

@kikyous the PR look fine, but can you add a test case ?

ok, I will try to add a test case.

kikyous commented 2 years ago

@seuros test case added

kikyous commented 2 years ago

@seuros ping

andyundso commented 11 months ago

In the meantime, if any one stumbles upon this, you can remove the select from the query that the gem adds with unscope.

class Stuff < ApplicationRecord
  acts_as_taggable

  has_many :things
end

class Thing < ApplicationRecord
  belongs_to :stuff
end

Thing.where(stuff: Stuff.tagged_with(["foo", "bar"], any: true).unscope(:select))