I think mysql used to just give a warning and maybe now it's an error? It
can currently be reproduced with just a blank project (using django master,
mysql 5.5.46-0ubuntu0.14.04.2):
mysql -e'create database mb4test charset utf8mb4'
django-admin startproject mb4test
cd mb4test
vi mb4test/settings.py # set up db settings
./manage.py migrate
Operations to perform:
Apply all migrations: auth, admin, sessions, contenttypes
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length...Traceback (most
recent call last):
File "/home/collin/django1.10/django/db/backends/utils.py", line 64, in
execute
return self.cursor.execute(sql, params)
File "/home/collin/django1.10/django/db/backends/mysql/base.py", line
112, in execute
return self.cursor.execute(query, args)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/cursors.py", line
226, in execute
self.errorhandler(self, exc, value)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/connections.py",
line 36, in defaulterrorhandler
raise errorvalue
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/cursors.py", line
217, in execute
res = self._query(query)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/cursors.py", line
378, in _query
rowcount = self._do_query(q)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/cursors.py", line
341, in _do_query
db.query(q)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/connections.py",
line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1071, 'Specified key was too long; max
key length is 767 bytes')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/collin/django1.10/django/core/management/__init__.py", line
349, in execute_from_command_line
utility.execute()
File "/home/collin/django1.10/django/core/management/__init__.py", line
341, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/collin/django1.10/django/core/management/base.py", line 290,
in run_from_argv
self.execute(*args, **cmd_options)
File "/home/collin/django1.10/django/core/management/base.py", line 339,
in execute
output = self.handle(*args, **options)
File
"/home/collin/django1.10/django/core/management/commands/migrate.py", line
177, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/home/collin/django1.10/django/db/migrations/executor.py", line 92,
in migrate
self._migrate_all_forwards(plan, full_plan, fake=fake,
fake_initial=fake_initial)
File "/home/collin/django1.10/django/db/migrations/executor.py", line
121, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake,
fake_initial=fake_initial)
File "/home/collin/django1.10/django/db/migrations/executor.py", line
198, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/collin/django1.10/django/db/migrations/migration.py", line
123, in apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
File "/home/collin/django1.10/django/db/migrations/operations/fields.py",
line 201, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/home/collin/django1.10/django/db/backends/base/schema.py", line
482, in alter_field
old_db_params, new_db_params, strict)
File "/home/collin/django1.10/django/db/backends/base/schema.py", line
634, in _alter_field
params,
File "/home/collin/django1.10/django/db/backends/base/schema.py", line
110, in execute
cursor.execute(sql, params)
File "/home/collin/django1.10/django/db/backends/utils.py", line 79, in
execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/collin/django1.10/django/db/backends/utils.py", line 64, in
execute
return self.cursor.execute(sql, params)
File "/home/collin/django1.10/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/collin/django1.10/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/collin/django1.10/django/db/backends/utils.py", line 64, in
execute
return self.cursor.execute(sql, params)
File "/home/collin/django1.10/django/db/backends/mysql/base.py", line
112, in execute
return self.cursor.execute(query, args)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/cursors.py", line
226, in execute
self.errorhandler(self, exc, value)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/connections.py",
line 36, in defaulterrorhandler
raise errorvalue
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/cursors.py", line
217, in execute
res = self._query(query)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/cursors.py", line
378, in _query
rowcount = self._do_query(q)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/cursors.py", line
341, in _do_query
db.query(q)
File
"/home/collin/mb4test/lib/python3.4/site-packages/MySQLdb/connections.py",
line 280, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1071, 'Specified key was too long; max
key length is 767 bytes')
On Wed, Dec 30, 2015 at 5:01 AM, Florian Apolloner <[email protected]>
wrote:
>
>
> On Monday, December 21, 2015 at 5:32:43 PM UTC+1, Tim Graham wrote:
>>
>> "This patch breaks on MySQL installations using the utf8mb4 charset,
>> because it breaks the index length limit - it comes out at a maximum of 254
>> * 4 = 1016 bytes whilst by default InnoDB can only index 767 bytes. I found
>> this because I am using utf8mb4 in django-mysql's tests.
>>
>
> Can the original Author of that quote shed more light on "breaking"? To my
> knowledge it just limits the size of the index to the first 767 byte and
> MySQL will give you a warning, so we should be fine, no?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" 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].
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/ac1bd7c0-6692-4caf-8087-0dc0208e6588%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/ac1bd7c0-6692-4caf-8087-0dc0208e6588%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" 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].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/CAFO84S5GzZX82QU4PkYh63VtQTeCyj9UftEqcvD-e6%3DazxvJDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.