-
-
Notifications
You must be signed in to change notification settings - Fork 478
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
Fix: Error when setting table name with inherit #1196
Fix: Error when setting table name with inherit #1196
Conversation
Error was thrown when table_name is set with inherit=True in base model. - add not inherited check jazzband#1195
- authors and changes docs updated
Codecov Report
@@ Coverage Diff @@
## master #1196 +/- ##
=======================================
Coverage 97.08% 97.08%
=======================================
Files 23 23
Lines 1271 1271
Branches 208 208
=======================================
Hits 1234 1234
Misses 19 19
Partials 18 18
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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 good to me! It would be great to have a test for this fix.
Thank you for reviewing, I have added a test. |
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.
LGTM, thanks for the test @muneeb706!
Now also compares the table name of the inherited (base) model, so that it's easier to see that the history table name is not inherited.
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 good! Thank you, @muneeb706, and also @theryanwalker for reviewing :)
Error was thrown when
table_name
is set with inherit=True in base model.inherited check added in the condition where
table_name
is checked for updating db table name.Description
inherited flag argument in
create_history_model
method is used in the condition wheretable_name
is checked. Condition at line 301 ofsimple_history.models
now look like this:if not inherited and self.table_name is not None:
Related Issue
Closes #1195.
Motivation and Context
I found this issue while looking for the solution of #1174.
In documentation it is not mentioned that table_name can't be used with inherit. It is implied that this should work, this inconsistency was the motivation.
How Has This Been Tested?
Ran tests locally using
runtests.py
with python (3.8,3.11) and django 4.1Types of changes
Checklist:
pre-commit run
command to format and lint.AUTHORS.rst
CHANGES.rst