#14796 closed (fixed)
inspectdb producing field names which are Python keywords
Reported by: | Owned by: | mmcnickle | |
---|---|---|---|
Component: | django-admin.py inspectdb | Version: | 1.2 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Similar to #1328; I had a case where inspectdb produced a model which uses a python keyword as a field in the model class.
- Django: 1.2.3
- Python: 2.6.5
- DB Driver: postgresql_psycopg2
I will attach an SQL file; it is from the Danbooru image server. The table which had the problems is "dmails"; the column is a foreign key column to the table "users".
Attachments (4)
Change History (9)
by , 14 years ago
Attachment: | danbooru.sql added |
---|
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
As suspected, this happens because one transformation made to field names after the verification against the Python keyword list (namely the striping of '_id'
from e.g. 'from_id'
) can result in a 'from'
introspected model field name. There are a couple of that kind of transformations.
comment:2 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
by , 14 years ago
Attachment: | move_keyword_check.diff added |
---|
Move the keyword check after the relations check/modifications
comment:3 by , 14 years ago
Has patch: | set |
---|
by , 14 years ago
Attachment: | 14796-move_keyword_check_with_tests.diff added |
---|
Improved the test by using the pre-existing stdout capture method, updated inspectdb.py to take advantage of it.
Schema of the database which inspectdb is failing on