-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
Add type validation for foreign key and one to one model consistency #1792
Conversation
@Abdeldjalil-H thank you for the PR! A few comments:
|
@henadzit thank you for your comments. I'll work on that. Btw do you think we should use |
I think either will work since Tortoise only supports abstract class inheritance. |
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.
@Abdeldjalil-H thank you for great work! I left a few more comments, please have a look!
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.
There is an issue with CHANGELOG formatting and CI is failing. Apart from that the changes look good to me!
CHANGELOG.rst
Outdated
Added | ||
^^^^^ | ||
- Added type validation for foreign key fields to ensure type safety. Now raises ``ValidationError`` when assigning foreign key values with incorrect model types (#1792) | ||
0.22.1 |
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.
Formatting doesn't look correct here.
I don't know if the tests are failing because of the changes or other things. Is the database cleared after each test case? @henadzit |
The test cases that are failing are based on |
@Abdeldjalil-H can you please rebase your changes and correct the CHANGELOG? I improved test isolation in #1816, maybe, it will resolve issues in this PR. |
c1d81cf
to
6e39956
Compare
Pull Request Test Coverage Report for Build 12412674345Details
💛 - Coveralls |
Added validation to ensure consistency between the foreign key's expected model type and the actual model instance being assigned. This addresses an issue where mismatched model types could lead to silent failures or confusing database errors.
Description
Key changes:
Motivation and Context
This fixes issue #1791 where inconsistencies between
ForeignKeyField
model parameter and actual model types were not caught.How Has This Been Tested?
Running tests.
Checklist: