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

STI 父模型和子模型的 ignored_columns 不一致时,缓存可能是错误的 #129

Open
OuYangJinTing opened this issue Jan 29, 2021 · 0 comments

Comments

@OuYangJinTing
Copy link
Contributor

OuYangJinTing commented Jan 29, 2021

class Animal < ApplicationRecord
  self.ignored_columns = [:name]
end

class Dog < Animal
  self.ignored_columns = []
end

def test_sti_ignored_columns_not_match
  animal = Animal.create(name: "Dog", type: "Dog")
  animal.expire_second_level_cache
  Animal.find(animal.id)

  assert_equal "Dog", Animal.fetch_by_uniq_keys(id: animal.id).name
end

------------------------------------------------------------------------------------------------------------------------------
bundle exec rake test result:
Failure:
FetchByUinqKeyTest#test_sti_ignored_columns_not_match [/Code/second_level_cache/test/fetch_by_uniq_key_test.rb:119]:                                                      
Expected: "Dog"                                                                                                                                                           
  Actual: nil
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

1 participant