MCPcopy
hub / github.com/django/django / test_refresh_for_update

Method test_refresh_for_update

tests/basic/tests.py:1059–1067  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1057
1058 @skipUnlessDBFeature("has_select_for_update")
1059 def test_refresh_for_update(self):
1060 a = Article.objects.create(pub_date=datetime.now())
1061 for_update_sql = connection.ops.for_update_sql()
1062
1063 with transaction.atomic(), CaptureQueriesContext(connection) as ctx:
1064 a.refresh_from_db(from_queryset=Article.objects.select_for_update())
1065 self.assertTrue(
1066 any(for_update_sql in query["sql"] for query in ctx.captured_queries)
1067 )
1068
1069 def test_refresh_with_related(self):
1070 a = Article.objects.create(pub_date=datetime.now())

Callers

nothing calls this directly

Calls 6

for_update_sqlMethod · 0.80
select_for_updateMethod · 0.80
createMethod · 0.45
nowMethod · 0.45
refresh_from_dbMethod · 0.45

Tested by

no test coverage detected