From f11d14caecc497a063d84143306f95d0027fad50 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 24 Sep 2011 10:32:39 -0400 Subject: [PATCH] - 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] --- CHANGES | 7 +++++++ lib/sqlalchemy/orm/session.py | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) 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() -- 2.47.3