Django

Code

Ticket #10358 (closed: fixed)

Opened 1 year ago

Last modified 10 months ago

manage.py sqlall is not truncating long table names for ManyToManyField

Reported by: jb0t Assigned to: jacob
Milestone: 1.1 Component: Documentation
Version: 1.0 Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

64_not_32.diff (1.1 kB) - added by deadwisdom on 03/31/09 18:24:44.

Change History

02/28/09 13:10:46 changed by jacob

  • needs_better_patch changed.
  • needs_docs changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • milestone set to 1.1.

03/14/09 00:25:54 changed by russellm

  • component changed from Uncategorized to Documentation.

03/31/09 18:22:27 changed by deadwisdom

  • owner changed from nobody to deadwisdom.

03/31/09 18:24:44 changed by deadwisdom

  • attachment 64_not_32.diff added.

03/31/09 18:25:23 changed by deadwisdom

  • has_patch set to 1.

04/02/09 13:42:57 changed by jacob

  • owner changed from deadwisdom to jacob.
  • status changed from new to assigned.

04/03/09 13:30:55 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

(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.

05/23/09 13:34:04 changed by ramiro

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.


Add/Change #10358 (manage.py sqlall is not truncating long table names for ManyToManyField)




Change Properties
Action