#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 David Sanders, 18 months ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

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)

comment:2 by Mariusz Felisiak, 18 months ago

Owner: changed from nobody to andriykohut
Status: newassigned

Sounds reasonable, this should also allow folks to fix previously rejected ticket on their own, e.g. #31847.

comment:3 by Mariusz Felisiak, 18 months ago

Triage Stage: AcceptedReady for checkin

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 18 months ago

Resolution: fixed
Status: assignedclosed

In f8172f4:

Fixed #34587 -- Allowed customizing table name normalization in inspectdb command.

Note: See TracTickets for help on using tickets.
Back to Top