#10358 closed (fixed)
manage.py sqlall is not truncating long table names for ManyToManyField
Reported by: | Jay Hargis | Owned by: | Jacob |
---|---|---|---|
Component: | Documentation | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If you have a ManyToManyField in your model, and it is comprised of long model and app names, you will find that when you use manage.py sqlall appname it will truncate at 64 characters, rather than 32 with a hash as described here
http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField
Attachments (1)
Change History (9)
comment:1 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
Component: | Uncategorized → Documentation |
---|
comment:3 by , 16 years ago
Owner: | changed from | to
---|
by , 16 years ago
Attachment: | 64_not_32.diff added |
---|
comment:4 by , 16 years ago
Has patch: | set |
---|
comment:5 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 by , 15 years ago
Actually, the note added to the docs is incorrect, as it was the content it replaced.
Django doesn't set a hard limit of 64 nor 32 characters on the names of the auto-generated m2m intermediary tables, is simply uses the max identifier length (provided by a DatabaseOperations.max_name_length()
method) reported by the backend, if any.
The Django MySQL DB backend doesn't define max_name_length()
and because of that the ORM machinery doesn't truncate the m2m table name at all. I suspect what the OP was seeing is MySQL showing its 64 chars limitation (a comment in the Django source seems to indicate that MySQL doesn't have a hard limit on the length of identifiers, but rather it only considers the first 64 chars to discern among them, I couldn't confirm this).
In contrast, in the Oracle case the RDBMS identifier hard limit is 30, this is correctly reported by the Django DB backend and so an identifier of length > 30 will get converted to a 30 char identifier composed of the original 26 first chars plus 4 chars of and MD5 hash.
Because of the above, IMHO the current note lacks generality and is a bit misleading even in the case of MySQL.
(In [10371]) Fixed a whole bunch of small docs typos, errors, and ommissions.
Fixes #8358, #8396, #8724, #9043, #9128, #9247, #9267, #9267, #9375, #9409, #9414, #9416, #9446, #9454, #9464, #9503, #9518, #9533, #9657, #9658, #9683, #9733, #9771, #9835, #9836, #9837, #9897, #9906, #9912, #9945, #9986, #9992, #10055, #10084, #10091, #10145, #10245, #10257, #10309, #10358, #10359, #10424, #10426, #10508, #10531, #10551, #10635, #10637, #10656, #10658, #10690, #10699, #19528.
Thanks to all the respective authors of those tickets.