From: Mike Bayer Date: Sat, 24 Sep 2011 14:32:39 +0000 (-0400) Subject: - The integer "id" used to link a mapped instance with X-Git-Tag: rel_0_7_3~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f11d14caecc497a063d84143306f95d0027fad50;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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] --- diff --git a/CHANGES b/CHANGES index c1c4b83b89..d3a5e4a33f 100644 --- a/CHANGES +++ b/CHANGES @@ -105,6 +105,13 @@ CHANGES 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 diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 01404b8ea5..3aa0d1de09 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -526,7 +526,7 @@ class Session(object): 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 @@ -1814,3 +1814,4 @@ def _state_session(state): pass return None +_new_sessionid = util.counter()