#16460: Add support for Index Length for MySQL-backed Models
-------------------------+----------------------------------------------
 Reporter:  umbrae@…     |          Owner:  nobody
     Type:  New feature  |         Status:  new
Milestone:               |      Component:  Database layer (models, ORM)
  Version:  SVN          |       Severity:  Normal
 Keywords:               |   Triage Stage:  Unreviewed
Has patch:  0            |  Easy pickings:  0
    UI/UX:  0            |
-------------------------+----------------------------------------------
 On occasion, it is useful to be able to specific a key length different
 than the field length for a field - this is particularly true with MySQL,
 whose index sizes are limited to 767 bytes in InnoDB.

 For example, I have a simple field like the following:

 {{{
 url = models.CharField(max_length=767, db_index=True)
 }}}

 Where all fields are UTF-8 characters, and hence 3 bytes each. This will
 issue a warning when I try to syncdb (and will full-on fail in south, as
 south bombs out on warnings):

 _mysql_exceptions.Warning: Specified key was too long; max key length is
 767 bytes

 What I'd like to be able to do is the following:

 {{{
 url = models.CharField(max_length=767, db_index=True, index_length=255)
 }}}

 Which will then change the CREATE INDEX sql to look like:

 {{{
 CREATE INDEX "some_table_a4b49ab" ON "some_table" ("url"(255));
 }}}

 This should no longer issue a warning in MySQL.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16460>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to