tortoise / tortoise/tortoise-orm

Cyclic references support

Open
#379 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Future Release
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.
If we try to have cyclic referencing foreign keys, the schemas won't generate

Describe the solution you'd like
Support cyclic references (can be extended to multiple references in general, with a support for reverse key chooses, like this )

Describe alternatives you've considered

  • Adding the constraint by hand in the code (not supported)
  • Not generating schemas and adding the constraint by hand in the database

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 reproducing schema generation for two entities with cyclic foreign-key references, then read the linked relationships documentation for the multiple-relationship cases. Trace the schema-generation path and existing relationship tests; done means cyclic references generate successfully without manual database constraints, including the relevant regression coverage.

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.