Fix nullify generic relationship

This commit is contained in:
Konsta Vesterinen
2014-01-20 21:30:54 +02:00
parent 6fab2703a1
commit c9b9ec93f9
2 changed files with 21 additions and 12 deletions

View File

@@ -50,6 +50,11 @@ class GenericAttributeImpl(attributes.ScalarAttributeImpl):
# Set us on the state.
dict_[self.key] = initiator
if initiator is None:
# Nullify relationship args
dict_[self.parent_token.id.key] = None
dict_[self.parent_token.discriminator.key] = None
else:
# Get the primary key of the initiator and ensure we
# can support this assignment.
mapper = class_mapper(type(initiator))

View File

@@ -28,6 +28,10 @@ class TestGenericForiegnKey(TestCase):
self.User = User
self.Event = Event
def test_set_as_none(self):
event = self.Event()
event.object = None
def test_set_manual_and_get(self):
user = self.User()