#21308: DatabaseError running tests with MySQL & utf8mb4 charset
----------------------------------------+--------------------
     Reporter:  Greg Barker <fletch@…>  |      Owner:  nobody
         Type:  Bug                     |     Status:  new
    Component:  contrib.auth            |    Version:  1.5
     Severity:  Normal                  |   Keywords:
 Triage Stage:  Unreviewed              |  Has patch:  0
Easy pickings:  0                       |      UI/UX:  0
----------------------------------------+--------------------
 Character set and collation set to utf8mb4:
 {{{
 $ cat /etc/mysql/my.cnf | grep utf8
 character-set-server = utf8mb4
 collation-server     = utf8mb4_general_ci
 }}}

 Create a new site
 {{{
 $ virtualenv test-env
 $ cd test-env
 $ source ./bin/activate
 (temp-test) $ pip install django
 (temp-test) $ pip install mysql-python
 (temp-test) $ django-admin.py startproject mysite
 }}}

 Update settings.py to use MySQL and create your database

 Then run the tests, hit the error
 {{{
 $ python mysite/manage.py test
 Creating test database for alias 'default'...
 DatabaseError: (1071, 'Specified key was too long; max key length is 767
 bytes')
 }}}

 MySQL query log reveals it fails on this statement:
 {{{
 CREATE TABLE `auth_customuser` (
     `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
     `password` varchar(128) NOT NULL,
     `last_login` datetime NOT NULL,
     `email` varchar(255) NOT NULL UNIQUE,
     `is_active` bool NOT NULL,
     `is_admin` bool NOT NULL,
     `date_of_birth` date NOT NULL
 )
 }}}

 Which originates from custom_user.py in django.contrib.auth.tests
 {{{
 class CustomUser(AbstractBaseUser):
     email = models.EmailField(verbose_name='email address',
 max_length=255, unique=True)
     is_active = models.BooleanField(default=True)
     is_admin = models.BooleanField(default=False)
     date_of_birth = models.DateField()
 }}}

 I think it should be like the User class, which does not specify the
 max_length, so it defaults the value to 75.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21308>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/078.f873a21a0450132163f172cf04a24041%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to