MCPcopy
hub / github.com/django/django / test_alias_after_annotation

Method test_alias_after_annotation

tests/annotations/tests.py:1388–1394  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1386 self.assertEqual(book.pubdate_year, book.pubdate.year)
1387
1388 def test_alias_after_annotation(self):
1389 qs = Book.objects.annotate(
1390 is_book=Value(1),
1391 ).alias(is_book_alias=F("is_book"))
1392 book = qs.first()
1393 self.assertIs(hasattr(book, "is_book"), True)
1394 self.assertIs(hasattr(book, "is_book_alias"), False)
1395
1396 def test_overwrite_annotation_with_alias(self):
1397 qs = Book.objects.annotate(is_book=Value(1)).alias(is_book=F("is_book"))

Callers

nothing calls this directly

Calls 5

ValueClass · 0.90
FClass · 0.90
aliasMethod · 0.80
annotateMethod · 0.80
firstMethod · 0.80

Tested by

no test coverage detected