Opened 2 years ago

Closed 9 months ago

#27533 closed Bug (fixed)

inspectdb crashes on unsupported unique_together constraints in PostgreSQL

Reported by: Wei Ma Owned by: Michael Sinov
Component: Database layer (models, ORM) Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

inspectdb command crashes when I try to generate model classes from postgres db.

the command I used was
python manage.py inspectdb > all_models.py

the error I got was:

File "/xxx/env/lib/python3.5/site-packages/django/core/management/commands/inspectdb.py", line 278, in <genexpr>

tup = '(' + ', '.join("'%s'" % column_to_field_name[c] for c in columns) + ')'

KeyError: None

Change History (8)

comment:1 Changed 2 years ago by Wei Ma

I created a PR https://github.com/django/django/pull/7618 for this bug.

comment:2 Changed 2 years ago by Max Resnick

comment:3 Changed 2 years ago by Tim Graham

Component: Core (Other)Database layer (models, ORM)
Needs tests: set
Summary: inspectdb command crashes when generate model classes from postgres dbinspectdb crashes on unsupported unique_together constraints in PostgreSQL
Triage Stage: UnreviewedAccepted

comment:4 Changed 2 years ago by Wei Ma

I have closed my PR https://github.com/django/django/pull/7618 due to not able to create test cases. If anyone want to help, please fork my repo and add needed tests.

comment:5 Changed 2 years ago by Michael Sinov

Needs tests: unset
Owner: changed from nobody to Michael Sinov
Status: newassigned

comment:6 Changed 22 months ago by felixxm

Has patch: unset
Patch needs improvement: set

comment:7 Changed 22 months ago by felixxm

Has patch: set

comment:8 Changed 9 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 9aca67be:

Fixed #27533 -- Fixed inspectdb crash if a unique constraint uses an unsupported type.

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