[Django] #34587: Allow to override table2model conversion for inspectdb command

10 views
Skip to first unread message

Django

unread,
May 22, 2023, 3:38:22 AM5/22/23
to django-...@googlegroups.com
#34587: Allow to override table2model conversion for inspectdb command
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
crunchy_crow |
Type: | Status: new
Uncategorized |
Component: Core | Version: 4.2
(Management commands) |
Severity: Normal | Keywords: inspectdb
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/34587>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 22, 2023, 4:20:12 AM5/22/23
to django-...@googlegroups.com
#34587: Allow to override table2model conversion for inspectdb command
-------------------------------------+-------------------------------------
Reporter: crunchy_crow | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Core (Management | Version: 4.2
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

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)

--
Ticket URL: <https://code.djangoproject.com/ticket/34587#comment:1>

Django

unread,
May 22, 2023, 4:24:50 AM5/22/23
to django-...@googlegroups.com
#34587: Allow to override table2model conversion for inspectdb command
-------------------------------------+-------------------------------------
Reporter: crunchy_crow | Owner:
Type: | andriykohut
Cleanup/optimization | Status: assigned

Component: Core (Management | Version: 4.2
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => andriykohut
* status: new => assigned


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/34587#comment:2>

Django

unread,
May 22, 2023, 7:14:01 AM5/22/23
to django-...@googlegroups.com
#34587: Allow to override table2model conversion for inspectdb command
-------------------------------------+-------------------------------------
Reporter: crunchy_crow | Owner:
Type: | andriykohut
Cleanup/optimization | Status: assigned
Component: Core (Management | Version: 4.2
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34587#comment:3>

Django

unread,
May 22, 2023, 1:23:32 PM5/22/23
to django-...@googlegroups.com
#34587: Allow to override table2model conversion for inspectdb command
-------------------------------------+-------------------------------------
Reporter: crunchy_crow | Owner:
Type: | andriykohut
Cleanup/optimization | Status: closed

Component: Core (Management | Version: 4.2
commands) |
Severity: Normal | Resolution: fixed

Keywords: inspectdb | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f8172f45fc83af2315aefed77ee34b5654f5c347" f8172f4]:
{{{
#!CommitTicketReference repository=""
revision="f8172f45fc83af2315aefed77ee34b5654f5c347"
Fixed #34587 -- Allowed customizing table name normalization in inspectdb
command.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34587#comment:4>

Reply all
Reply to author
Forward
0 new messages