Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29778 closed Bug (fixed)

Unique index cannot be created for db table, whose name should be quoted

Reported by: Oleg Owned by: Oleg
Component: Database layer (models, ORM) Version: 2.1
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It is not possible to create unqiue indexes for tables, whose names should be quoted, for example db_table = 'test-table' .
ORM does not quote index name, so exception is raised:

return Database.Cursor.execute(self, query, params)
E django.db.utils.OperationalError: near "-": syntax error

This was supported in version 1.11 and should be work according to documentation:

If your database table name is an SQL reserved word, or contains characters that aren’t allowed in Python variable names – notably, the hyphen – that’s OK. Django quotes column and table names behind the scenes.

Change History (5)

comment:1 by Carlton Gibson, 6 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:2 by Carlton Gibson, 6 years ago

comment:3 by Carlton Gibson, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In d1d5c97b:

Fixed #29778 -- Fixed quoting of unique index names.

Regression in 3b429c96736b8328c40e5d77282b0d30de563c3c.

comment:5 by Tim Graham <timograham@…>, 6 years ago

In cdb8ee7:

[2.1.x] Fixed #29778 -- Fixed quoting of unique index names.

Regression in 3b429c96736b8328c40e5d77282b0d30de563c3c.
Backport of d1d5c97bc2821bf8c0f4b2d9c7ab16200845b494 from master.

Note: See TracTickets for help on using tickets.
Back to Top