tortoise / tortoise/tortoise-orm

M2M Field Alternative PK

Open
#463 0 comments 0 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

Is your feature request related to a problem? Please describe.
I would like to be able to specify an alternative field to be used as the PK in a M2M relation.

Describe the solution you'd like
When declaring a M2M field I would like to optionally set alternative_pk='other_id'

Describe alternatives you've considered
Secondary PKs?

Additional context
Might be bad design, but I'm read only here and it would be nice to have.

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

The issue names no files or tests. Start by tracing how many-to-many fields are declared and how their primary keys are resolved; done would mean an optional alternative_pk such as other_id is supported for the relation, with coverage for the resulting behavior.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.