tortoise / tortoise/tortoise-orm

Allow adding and removing m2m fields using id

Open
#953 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

The add() and remove() functions on the m2m field currently only accept instances of the related model.

It would be useful if it also accepted ids of the related model. This would avoid having to query the database to fetch the instances just to add or remove them.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the m2m field's add() and remove() entry points and how they currently validate related-model instances. Confirm the expected behavior for related-model ids, including avoiding an instance-fetch query, and verify that both operations accept ids while retaining existing instance support.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.