MCPcopy Index your code
hub / github.com/tortoise/tortoise-orm / test_prefetch_m2m

Function test_prefetch_m2m

tests/test_prefetching.py:51–62  ·  view source on GitHub ↗
(db)

Source from the content-addressed store, hash-verified

49
50@pytest.mark.asyncio
51async def test_prefetch_m2m(db):
52 tournament = await Tournament.create(name="tournament")
53 event = await Event.create(name="First", tournament=tournament)
54 team = await Team.create(name="1")
55 team_second = await Team.create(name="2")
56 await event.participants.add(team, team_second)
57 fetched_events = (
58 await Event.all()
59 .prefetch_related(Prefetch("participants", queryset=Team.filter(name="1")))
60 .first()
61 )
62 assert len(fetched_events.participants) == 1
63
64
65@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 7

PrefetchClass · 0.90
addMethod · 0.80
createMethod · 0.45
firstMethod · 0.45
prefetch_relatedMethod · 0.45
allMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…