mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Refs #28586 - Copied fetch mode in QuerySet.create().
This change allows the pattern `MyModel.objects.fetch_mode(...).create(...)` to set the fetch mode for a new object.
This commit is contained in:
committed by
Jacob Walls
parent
6dc9b04018
commit
e244d8bbb7
@@ -290,6 +290,13 @@ class ModelTest(TestCase):
|
||||
)
|
||||
self.assertEqual(Article.objects.get(headline="Article 10"), a10)
|
||||
|
||||
def test_create_method_propagates_fetch_mode(self):
|
||||
article = Article.objects.fetch_mode(models.FETCH_PEERS).create(
|
||||
headline="Article 10",
|
||||
pub_date=datetime(2005, 7, 31, 12, 30, 45),
|
||||
)
|
||||
self.assertEqual(article._state.fetch_mode, models.FETCH_PEERS)
|
||||
|
||||
def test_year_lookup_edge_case(self):
|
||||
# Edge-case test: A year lookup should retrieve all objects in
|
||||
# the given year, including Jan. 1 and Dec. 31.
|
||||
|
||||
Reference in New Issue
Block a user