Commits

Mike Bayer  committed 4dfaa40

- The integer "id" used to link a mapped instance with
its owning Session is now generated by a sequence
generation function rather than id(Session), to
eliminate the possibility of recycled id() values
causing an incorrect result, no need to check that
object actually in the session. [ticket:2280]

  • Participants
  • Parent commits b08a5ff

Comments (0)

Files changed (2)

         to the mapper after it has already been configured.
         [ticket:2239]
 
+   - The integer "id" used to link a mapped instance with
+     its owning Session is now generated by a sequence
+     generation function rather than id(Session), to
+     eliminate the possibility of recycled id() values 
+     causing an incorrect result, no need to check that 
+     object actually in the session.  [ticket:2280]
+
 -sql
   - Behavioral improvement: empty
     conjunctions such as and_() and or_() will be

File lib/sqlalchemy/orm/session.py

         self.__binds = {}
         self._flushing = False
         self.transaction = None
-        self.hash_key = id(self)
+        self.hash_key = _new_sessionid()
         self.autoflush = autoflush
         self.autocommit = autocommit
         self.expire_on_commit = expire_on_commit
             pass
     return None
 
+_new_sessionid = util.counter()