From e5b6c7bc334c52c22ae1c5199a802fa3649290cb Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 5 Jan 2008 18:26:28 +0000 Subject: - fixed fairly critical bug whereby the same instance could be listed more than once in the unitofwork.new collection; most typically reproduced when using a combination of inheriting mappers and ScopedSession.mapper, as the multiple __init__ calls per instance could save() the object with distinct _state objects --- lib/sqlalchemy/orm/attributes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 21b8a4e64..91bf13034 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -1122,7 +1122,8 @@ def register_class(class_, extra_init=None, on_exception=None, deferred_scalar_l doinit = False def init(instance, *args, **kwargs): - instance._state = InstanceState(instance) + if not hasattr(instance, '_state'): + instance._state = InstanceState(instance) if extra_init: extra_init(class_, oldinit, instance, args, kwargs) -- cgit v1.2.1