Opened 18 months ago
Closed 18 months ago
#34587 closed Cleanup/optimization (fixed)
Allow to override table2model conversion for inspectdb command
Reported by: | crunchy_crow | Owned by: | andriykohut |
---|---|---|---|
Component: | Core (Management commands) | Version: | 4.2 |
Severity: | Normal | Keywords: | inspectdb |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
When implementing a custom inspectdb command by inheriting from inspectdb.Command
users should be able to override the table name to model conversion logic.
Public method for column names already exists: https://github.com/django/django/blob/00f5d2d110712af84fae2c5f9183a2ea48ce0a4a/django/core/management/commands/inspectdb.py#L265
This would allow overriding the default behaviour of command in a custom inspectdb
, for example when table names are already PascalCase (i.e. schema.FooBarBuzz
), etc. With default implementation, it will be converted into class SchemaFoobarbuzz(models.Model)
.
Proposed PR: https://github.com/django/django/pull/16883
Change History (4)
comment:1 by , 18 months ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 18 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Sounds reasonable, this should also allow folks to fix previously rejected ticket on their own, e.g. #31847.
comment:3 by , 18 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
Seems like a valid request 👍
✔️ small & isolated refactor
✔️ no behaviour change
✔️ aids extendability
✔️ more consistent
✔️ PR already in place
Accepting :) (though it may still be rejected by someone else)