Opened 5 years ago

Closed 5 years ago

#28875 closed Bug (wontfix)

SQL: Creation of Index fails with '/' in app_label

Reported by: Jens L. Owned by: nobody
Component: Database layer (models, ORM) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jens L.)

Django 2's creation of SQLite indicies doesn't escape the index name, which causes issues when you use for example '/' in your app_labels.

Offending file is db/backends/sqlite3/schema.py , line 18.

If said line is swapped with this:

    sql_create_unique = "CREATE UNIQUE INDEX \"%(name)s\" ON %(table)s (%(columns)s)"

creation of indices works fine.

Update: This also happens on MySQL (tested on Python 3.5.3, Django 2.0, PyMySQL 0.7.11

Change History (2)

comment:1 Changed 5 years ago by Jens L.

Description: modified (diff)
Summary: SQLite: Creation of Index fails with '/' in app_labelSQL: Creation of Index fails with '/' in app_label

comment:2 Changed 5 years ago by Simon Charette

Resolution: wontfix
Status: newclosed

As documented, app labels should be a valid Python identifiers.

I'm afraid that excludes slashes.

python3 -c "assert 'foo/bar'.isidentifier()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AssertionError
Note: See TracTickets for help on using tickets.
Back to Top