#32234 closed Cleanup/optimization (fixed)
inspectdb should inform about composite keys.
| Reported by: | Damien | Owned by: | Anvesh Mishra |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | 3.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Ad Timmering | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Since django does not support multiple multiple-column primary keys, there should be a warning that the inspectdb result does not match exactly the database
Change History (16)
comment:1 by , 5 years ago
| Easy pickings: | unset |
|---|---|
| Has patch: | set |
| Needs tests: | set |
| Owner: | changed from to |
| Patch needs improvement: | set |
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 5 years ago
| Component: | Database layer (models, ORM) → Core (Management commands) |
|---|---|
| Summary: | Add warning when multiple-column primary keys are found when using inspectdb → inspectdb should inform about composite keys. |
| Type: | New feature → Cleanup/optimization |
comment:3 by , 5 years ago
| Description: | modified (diff) |
|---|
comment:4 by , 5 years ago
Updated the PR to change the warning to be a comment instead of printing it to stderr
comment:5 by , 4 years ago
| Cc: | added |
|---|
comment:6 by , 3 years ago
| Owner: | changed from to |
|---|
comment:7 by , 3 years ago
I actually found a solution to this in SQLite3 through PRAGMA keyword but since PRAGMA is a SQLite3 specific command so my PR didn't passed the Jenkins tests https://github.com/django/django/pull/15683. If you could provide any suggestions cause if we use get_constraint method to fetch the primary key it only takes the first column as primary key and gives no info if there were other primary-key columns. Also I tried the changes given in PR https://github.com/django/django/pull/13736 but they didn't work.
comment:8 by , 3 years ago
Submitted a new PR with all the required changes. https://github.com/django/django/pull/15730
comment:9 by , 3 years ago
| Needs documentation: | set |
|---|
comment:10 by , 3 years ago
| Needs documentation: | unset |
|---|---|
| Needs tests: | unset |
| Patch needs improvement: | unset |
| Triage Stage: | Accepted → Ready for checkin |
inspectdbis meant as a shortcut, not as definitive model generation. I would rather add a comment to the field'snoteslike we do in other cases. Raising a warning can be really annoying when you try to inspect a legacy database.