-
-
Notifications
You must be signed in to change notification settings - Fork 444
feat: foreignkey to model class #2027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #2027 will not alter performanceComparing Summary
|
Pull Request Test Coverage Report for Build 20420146382Details
💛 - Coveralls |
henadzit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great addition!
Does it actually work though? Can you please add tests with "self" and classes passed to relations. Thanks!
tortoise/fields/relational.py
Outdated
| def validate_model_name(cls, model_name: str | type[Model]) -> None: | ||
| if not isinstance(model_name, str): | ||
| model_class: type[Model] = model_name | ||
| if not hasattr(model_class, "_meta"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check for that more precisely:
issubclass(child_type, parent_type)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent_type is tortoise.models.Model, which will cause a import cycle if I use issubclass
…foreignkey-to-model
…foreignkey-to-model
…foreignkey-to-model
…foreignkey-to-model
Description
Motivation and Context
To support Django style foreignkey/o2o/m2m
How Has This Been Tested?
make ci
Checklist: