-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
I'm seeing some confusing behavior where the IdentityMap seems to hold on to the class of given objects in a relationship, such that if the object changes _type, no amount of reloading the relationship will cause it to reload. See below for examples:
ruby class Band include Mongoid::Document has_many :musicians end class RockBand < Band end class JazzBand < Band end class Musician include Mongoid::Document belongs_to :band end b = RockBand.create() m = Musician.create(:band_id => b.id) b.write_attribute('_type', JazzBand.name) b.save() b.reload() b.class # => RockBand m.band.reload().class # => RockBand m.reload().band.class # => RockBand m.reload().band.reload().class # => RockBand Mongoid::IdentityMap.clear() m.reload().band.class # => JazzBand
It seems like the m.reload().band.class should cause the musician to be reloaded so it picks up that the band on the other side of the relationship is now a JazzBand.