Opened 16 years ago
Closed 16 years ago
#11658 closed (fixed)
mysql backend doesn't define a max_name_length()
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
MySql has a limit on the length of table, constaint, etc. names
(http://dev.mysql.com/doc/refman/4.1/en/identifiers.html), however, a
max_name_length() is not defined in django/db/backends/mysql/base.py
This means that long model names can trigger #1820 (In my case, a name
of a constraint was too long, ending up triggering this bug, even
though comment no. 6 on that ticket (http://code.djangoproject.com/ticket/1820#comment:6)
claims that is solved for constaints.)
Another comment might be comment no. 7 on #10358
(http://code.djangoproject.com/ticket/10358#comment:7) which mentions
a lack of max_name_length() but somehow doesn't consider this a
problem.
In my case, adding the following:
def max_name_length(self):
return 64
to DatabaseOperations in django/db/backends/mysql/base.py appears to
solve the
_mysql_exceptions.OperationalError: (1059, "Identifier name 'somelongmodelname_id_refs_question_ptr_id_8c9b12fefd7d140' is too long")
problem
Change History (2)
comment:1 by , 16 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Version: | 1.0 → SVN |
comment:2 by , 16 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Fixed in #13040.