parent
0192e9a976
commit
7b159df942
|
@ -273,18 +273,17 @@ class BasicExpressionsTests(TestCase):
|
||||||
def test_object_update_fk(self):
|
def test_object_update_fk(self):
|
||||||
# F expressions cannot be used to update attributes which are foreign
|
# F expressions cannot be used to update attributes which are foreign
|
||||||
# keys, or attributes which involve joins.
|
# keys, or attributes which involve joins.
|
||||||
def test():
|
test_gmbh = Company.objects.get(pk=self.gmbh.pk)
|
||||||
self.gmbh.point_of_contact = F('ceo')
|
|
||||||
msg = 'F(ceo)": "Company.point_of_contact" must be a "Employee" instance.'
|
msg = 'F(ceo)": "Company.point_of_contact" must be a "Employee" instance.'
|
||||||
with self.assertRaisesMessage(ValueError, msg):
|
with self.assertRaisesMessage(ValueError, msg):
|
||||||
test()
|
test_gmbh.point_of_contact = F('ceo')
|
||||||
|
|
||||||
self.gmbh.point_of_contact = self.gmbh.ceo
|
test_gmbh.point_of_contact = self.gmbh.ceo
|
||||||
self.gmbh.save()
|
test_gmbh.save()
|
||||||
self.gmbh.name = F('ceo__last_name')
|
test_gmbh.name = F('ceo__last_name')
|
||||||
msg = 'Joined field references are not permitted in this query'
|
msg = 'Joined field references are not permitted in this query'
|
||||||
with self.assertRaisesMessage(FieldError, msg):
|
with self.assertRaisesMessage(FieldError, msg):
|
||||||
self.gmbh.save()
|
test_gmbh.save()
|
||||||
|
|
||||||
def test_object_update_unsaved_objects(self):
|
def test_object_update_unsaved_objects(self):
|
||||||
# F expressions cannot be used to update attributes on objects which do
|
# F expressions cannot be used to update attributes on objects which do
|
||||||
|
|
Loading…
Reference in New Issue