tortoise / tortoise/tortoise-orm
I need OuterRef
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
i need outerref to create prefetch & limit
Describe the solution you'd like
A clear and concise description of what you want to happen.
post_prefetch = Prefetch("posts",Post.filter(user_id=OuterRef("id")).limit(5)))
user_posts = await User.all().prefetch_related(post_prefetch)
result:
>>> user_posts[0].posts
[post 1, post 2, post 3, post 4, post 5]
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the feature request here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the Prefetch and prefetch_related entry points mentioned in the issue, along with how query limits are currently handled. Determine whether the requested OuterRef behavior can support a limited, per-user prefetch, and define completion as returning up to five posts for each user's relation as shown in the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100