Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot work with default scope #25

Open
huobazi opened this issue Jan 16, 2019 · 4 comments
Open

cannot work with default scope #25

huobazi opened this issue Jan 16, 2019 · 4 comments

Comments

@huobazi
Copy link

huobazi commented Jan 16, 2019

when use acts_as_paranoid

irb(main):001:0> Topic.all_tags
  (2.8ms)  SELECT tag FROM (SELECT DISTINCT unnest(topics.tags) as tag FROM "topics") subquery WHERE "topics"."deleted_at" IS NULL
Traceback (most recent call last):
        1: from (irb):1
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  missing FROM-clause entry for table "topics")
LINE 1: ...topics.tags) as tag FROM "topics") subquery WHERE "topics"."...
                                                             ^
: SELECT tag FROM (SELECT DISTINCT unnest(topics.tags) as tag FROM "topics") subquery WHERE "topics"."deleted_at" IS NULL



irb(main):002:0> Topic.unscoped.all_tags
   (3.8ms)  SELECT tag FROM (SELECT DISTINCT unnest(topics.tags) as tag FROM "topics") subquery
=> ["recommend", "adapter",  "emojionearea", "hello", "emojione"]
irb(main):003:0>
@skatkov
Copy link
Collaborator

skatkov commented Jan 16, 2019

Which gem version are you using?

I had a similar issue in my codebase and I fixed it here:
b23cad3

This should be working for 0.5.1 version.

@huobazi
Copy link
Author

huobazi commented Jan 16, 2019

@skatkov but, my gem version is 😢

    acts-as-taggable-array-on (0.5.1)

@skatkov
Copy link
Collaborator

skatkov commented Jan 16, 2019

Based on information you provided, I really have no clue what could be wrong here.

@huobazi
Copy link
Author

huobazi commented Jan 17, 2019

i reproduce the problem, see the codebase, the Gemfile.lock also uploaded with the commit

run rspec will got many failures via the generated sql ... subquery WHERE "users"."updated_at" IS NULL ...

the full output is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants