mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #31382 -- Made Model.save(update_fields=...) raise ValueError on non-concrete fields.
This commit is contained in:
committed by
Mariusz Felisiak
parent
94ea79be13
commit
8954f255bb
@@ -5,7 +5,10 @@ from .models import Account, Employee, Person, Profile, ProxyEmployee
|
||||
|
||||
|
||||
class UpdateOnlyFieldsTests(TestCase):
|
||||
msg = 'The following fields do not exist in this model or are m2m fields: %s'
|
||||
msg = (
|
||||
'The following fields do not exist in this model, are m2m fields, or '
|
||||
'are non-concrete fields: %s'
|
||||
)
|
||||
|
||||
def test_update_fields_basic(self):
|
||||
s = Person.objects.create(name='Sara', gender='F')
|
||||
@@ -254,3 +257,8 @@ class UpdateOnlyFieldsTests(TestCase):
|
||||
self.assertEqual(Person.objects.count(), 1)
|
||||
with self.assertNumQueries(2):
|
||||
s.save(update_fields=['name', 'employee_num'])
|
||||
|
||||
def test_update_non_concrete_field(self):
|
||||
profile_boss = Profile.objects.create(name='Boss', salary=3000)
|
||||
with self.assertRaisesMessage(ValueError, self.msg % 'non_concrete'):
|
||||
profile_boss.save(update_fields=['non_concrete'])
|
||||
|
||||
Reference in New Issue
Block a user