Skip to content

feat: rewrote the method for getting m2m objects#2205

Open
VladislavYar wants to merge 2 commits into
tortoise:developfrom
VladislavYar:expanding-prefetch-capabilities
Open

feat: rewrote the method for getting m2m objects#2205
VladislavYar wants to merge 2 commits into
tortoise:developfrom
VladislavYar:expanding-prefetch-capabilities

Conversation

@VladislavYar
Copy link
Copy Markdown

Description

The _prefetch_m2m_relation method of the BaseExecutor class has been rewritten. Now objects are received directly through the specified queryset, which allows you to correctly use select_related, annotate, etc.

Motivation and Context

prefetch_related (m2m) functionality becomes like in Django.

How Has This Been Tested?

Added tests to tests/test_prefetching.py with verification of receiving data from annotate and select_related.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 27, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing VladislavYar:expanding-prefetch-capabilities (f16c511) with develop (179ea6f)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant