diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2019-08-17 15:30:29 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-08-19 13:28:35 +0200 |
| commit | 85458e94e38c20e57939947ee515a1a53689659f (patch) | |
| tree | 8011012c857d0a8f462e55c4eb20913afb19657b /tests/basic/tests.py | |
| parent | e9f74f53ccbf897ed69a484f35d616e1914d2c90 (diff) | |
Fixed #29260 -- Skipped an UPDATE when adding a model instance with primary key that has a default.
Diffstat (limited to 'tests/basic/tests.py')
| -rw-r--r-- | tests/basic/tests.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py index b29dda64f7..89f6048c96 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -10,7 +10,10 @@ from django.test import ( ) from django.utils.translation import gettext_lazy -from .models import Article, ArticleSelectOnSave, FeaturedArticle, SelfRef +from .models import ( + Article, ArticleSelectOnSave, FeaturedArticle, PrimaryKeyWithDefault, + SelfRef, +) class ModelInstanceCreationTests(TestCase): @@ -130,6 +133,11 @@ class ModelInstanceCreationTests(TestCase): # ... but there will often be more efficient ways if that is all you need: self.assertTrue(Article.objects.filter(id=a.id).exists()) + def test_save_primary_with_default(self): + # An UPDATE attempt is skipped when a primary key has default. + with self.assertNumQueries(1): + PrimaryKeyWithDefault().save() + class ModelTest(TestCase): def test_objects_attribute_is_only_available_on_the_class_itself(self): |
