mirror of
https://github.com/django/django.git
synced 2025-04-16 21:34:37 +00:00
This commit is contained in:
parent
764af7a3d6
commit
02e7a162a0
@ -148,6 +148,12 @@ class DbDefaultModel(models.Model):
|
||||
name = models.CharField(max_length=10)
|
||||
created_at = models.DateTimeField(db_default=Now())
|
||||
|
||||
class Meta:
|
||||
required_db_features = {"supports_expression_defaults"}
|
||||
|
||||
|
||||
class DbDefaultPrimaryKey(models.Model):
|
||||
id = models.DateTimeField(primary_key=True, db_default=Now())
|
||||
|
||||
class Meta:
|
||||
required_db_features = {"supports_expression_defaults"}
|
||||
|
@ -845,6 +845,7 @@ class BulkCreateTests(TestCase):
|
||||
],
|
||||
)
|
||||
|
||||
@skipUnlessDBFeature("supports_expression_defaults")
|
||||
def test_db_default_field_excluded(self):
|
||||
# created_at is excluded when no db_default override is provided.
|
||||
with self.assertNumQueries(1) as ctx:
|
||||
@ -869,7 +870,9 @@ class BulkCreateTests(TestCase):
|
||||
2 if connection.features.can_return_rows_from_bulk_insert else 1,
|
||||
)
|
||||
|
||||
@skipUnlessDBFeature("can_return_rows_from_bulk_insert")
|
||||
@skipUnlessDBFeature(
|
||||
"can_return_rows_from_bulk_insert", "supports_expression_defaults"
|
||||
)
|
||||
def test_db_default_primary_key(self):
|
||||
(obj,) = DbDefaultPrimaryKey.objects.bulk_create([DbDefaultPrimaryKey()])
|
||||
self.assertIsInstance(obj.id, datetime)
|
||||
|
Loading…
x
Reference in New Issue
Block a user