Opened 12 years ago

Closed 12 years ago

#18843 closed Bug (fixed)

manage.py inspectdb raises TypeError for columns containing '%'

Reported by: Andy Terra Owned by: nobody
Component: Core (Management commands) Version: 1.4
Severity: Normal Keywords: inspectdb, TypeError
Cc: shai@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

python manage.py inspectdb --database=foo

class Foobar(models.Model):
TypeError: not enough arguments for format string

I've since inspected the database and spotted fields such as...

"PARTIC _(%)_PRÉ"
"Participação_de_Recarga_no_GROSS_(%)"

...which I believe are causing this error.

Change History (9)

comment:1 by Claude Paroz, 12 years ago

Triage Stage: UnreviewedAccepted

I plan to commit first #12460, then it should be easier to fix this one.

comment:2 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [f5ea730dac0986b2d48889a2d0fab2c5befb4494]:

Fixed #18843 -- Replaced more special chars in column names (inspectdb)

Thanks airstrike for the report.

comment:3 by Claude Paroz, 12 years ago

I'm not absolutely sure to have fixed your precise problem. At least, the non-ascii chars stuff is the subject of ticket #16737.

comment:4 by Anssi Kääriäinen, 12 years ago

Resolution: fixed
Status: closedreopened

This breaks tests on Oracle. Oracle fails to handle the '%' char in table creation at base.py:700. One possible fix here https://github.com/akaariai/django/tree/ticket_18843_fix

This is a quick & dirty fix. There might be some deeper problem in the Oracle backend's handling of table creation query strings, but I am too tired to begin inspecting that possibility.

comment:5 by Claude Paroz, 12 years ago

Is there any other special character in Oracle that is accepted in a table name but would be replaced by re.subn(r'\W', '_', new_name)?

comment:6 by EmilStenstrom, 12 years ago

Easy pickings: unset

Due to the requirement to test this against multiple databases (one being Oracle) and the fact that an existing patch exists, I'm removing easy_pickings from this one. Please revert if you don't agree.

comment:7 by Shai Berger, 12 years ago

Cc: shai@… added

I believe the fix for this problem has already been committed, to master before 1.5 was branched, by @akaariai.

comment:8 by Aymeric Augustin, 12 years ago

Anssi recently confirmed that the test suite passes on Oracle (+ Python 3, but that doesn't matter here). So it's probably fixed indeed.

comment:9 by Aymeric Augustin, 12 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.
Back to Top