diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-08 10:50:13 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-08 10:50:13 -0400 |
| commit | 50176cf290767b6dbd2e361b4440d308328be173 (patch) | |
| tree | ded7423dc4773d9b2070567a3bf6f5f91141e1dd /lib/sqlalchemy | |
| parent | 633bba65f9be6a74162ed2ed8563f1e5ced2330d (diff) | |
| download | sqlalchemy-50176cf290767b6dbd2e361b4440d308328be173.tar.gz | |
added an extra check for the correct class when __init__ is called,
to fix the second half of [ticket:1846]
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index e98740287..2405d91c0 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -1118,6 +1118,15 @@ class ClassManager(dict): """ if hasattr(instance, self.STATE_ATTR): return False + elif self.class_ is not instance.__class__ and \ + self.is_mapped: + # this will create a new ClassManager for the + # subclass, without a mapper. This is likely a + # user error situation but allow the object + # to be constructed, so that it is usable + # in a non-ORM context at least. + return self._subclass_manager(instance.__class__).\ + _new_state_if_none(instance) else: state = self._create_instance_state(instance) setattr(instance, self.STATE_ATTR, state) |
