Opened 13 years ago
Closed 12 years ago
#16737 closed Bug (fixed)
inspectdb does not handle non-ascii column names correctly
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.3 |
Severity: | Normal | Keywords: | inspectdb |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When a database I am inspecting has a columnname of "TamañoFuente", inspectdb fails as it is unable to write "\xf1" as a valid ascii character.
It probably requires a proper #encoding: header, and some sort of logic to make proper python identifiers out of such names.
Attachments (1)
Change History (6)
comment:1 by , 13 years ago
Keywords: | inspectdb added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
Component: | ORM aggregation → Database layer (models, ORM) |
---|
comment:4 by , 12 years ago
Current code is outputting the db_column name with the \x escape notation (for ex. db_column='tama\xf1o'), due to the repr() call on the value. Is this acceptable?
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Non-ASCII identifiers are only supported by Python 3, so we'll have to convert the column name to ASCII.
To fix this, we have to:
inspectdb
writes the file in utf-8# coding: utf-8
at the top of the fileunicodedata.normalize('NFKD', column_name).encode('ascii', 'ignore')
db_column
on the field