Skip to content

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

Description

@OuYangJinTing
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions