Fix nullify generic relationship
This commit is contained in:
@@ -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))
|
||||
|
@@ -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()
|
||||
|
||||
|
Reference in New Issue
Block a user