Opened 3 years ago

Closed 3 years ago

#18843 closed Bug (fixed)

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

Reported by: airstrike 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 Changed 3 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

comment:2 Changed 3 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In [f5ea730dac0986b2d48889a2d0fab2c5befb4494]:

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

Thanks airstrike for the report.

comment:3 Changed 3 years ago by claudep

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 Changed 3 years ago by akaariai

  • Resolution fixed deleted
  • Status changed from closed to reopened

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 Changed 3 years ago by claudep

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 Changed 3 years ago by EmilStenstrom

  • 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 Changed 3 years ago by shai

  • 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 Changed 3 years ago by aaugustin

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 Changed 3 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.
Back to Top