mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #470 -- Added support for database defaults on fields.
Special thanks to Hannes Ljungberg for finding multiple implementation gaps. Thanks also to Simon Charette, Adam Johnson, and Mariusz Felisiak for reviews.
This commit is contained in:
committed by
Mariusz Felisiak
parent
599f3e2cda
commit
7414704e88
@@ -20,6 +20,7 @@ from .models import (
|
||||
ArticleSelectOnSave,
|
||||
ChildPrimaryKeyWithDefault,
|
||||
FeaturedArticle,
|
||||
PrimaryKeyWithDbDefault,
|
||||
PrimaryKeyWithDefault,
|
||||
SelfRef,
|
||||
)
|
||||
@@ -175,6 +176,11 @@ class ModelInstanceCreationTests(TestCase):
|
||||
with self.assertNumQueries(1):
|
||||
PrimaryKeyWithDefault().save()
|
||||
|
||||
def test_save_primary_with_db_default(self):
|
||||
# An UPDATE attempt is skipped when a primary key has db_default.
|
||||
with self.assertNumQueries(1):
|
||||
PrimaryKeyWithDbDefault().save()
|
||||
|
||||
def test_save_parent_primary_with_default(self):
|
||||
# An UPDATE attempt is skipped when an inherited primary key has
|
||||
# default.
|
||||
|
||||
Reference in New Issue
Block a user