-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
Mongoid documents with versioning included and with enabled identity map get stale after updates.
It goes like this:
1) Get object.
2) Update it.
3) save! it.
4) .find(id) returns old version, before update.
It happens with Mongoid 2.3.3
Code to reproduce:
# connect to mongo Mongoid.config.identity_map_enabled # true class Bong include Mongoid::Document include Mongoid::Versioning field :session_cookie, type: String index :session_cookie end Bong.create!(session_cookie: "111") #<Bong _id: 4eba2d2d530a691d13000001, _type: nil, version: 1, session_cookie: "111"> b = Bong.find('4eba2d2d530a691d13000001') #<Bong _id: 4eba2d2d530a691d13000001, _type: nil, version: 1, session_cookie: "111"> b.session_cookie = '222' b.save! b = Bong.find('4eba2d2d530a691d13000001') #<Bong _id: 4eba2d2d530a691d13000001, _type: nil, version: 1, session_cookie: "111"> b.session_cookie "111" b.versions #[]