﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30371	sqlmigrate fails with string defaults on mysql	Melvyn Sopacua	nobody	"When we have a migration that is adding strings defaults to a field, sqlmigrate will fail:

{{{
  File ""/home/melvyn/.local/py-env/button3d-7LYQbQGk/lib/python3.6/site-packages/django/db/migrations/migration.py"", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File ""/home/melvyn/.local/py-env/button3d-7LYQbQGk/lib/python3.6/site-packages/django/db/migrations/operations/fields.py"", line 84, in database_forwards
    field,
  File ""/home/melvyn/.local/py-env/button3d-7LYQbQGk/lib/python3.6/site-packages/django/db/backends/mysql/schema.py"", line 42, in add_field
    super().add_field(model, field)
  File ""/home/melvyn/.local/py-env/button3d-7LYQbQGk/lib/python3.6/site-packages/django/db/backends/base/schema.py"", line 435, in add_field
    self.execute(sql, params)
  File ""/home/melvyn/.local/py-env/button3d-7LYQbQGk/lib/python3.6/site-packages/django/db/backends/base/schema.py"", line 128, in execute
    self.collected_sql.append((sql % tuple(map(self.quote_value, params))) + ending)
  File ""/home/melvyn/.local/py-env/button3d-7LYQbQGk/lib/python3.6/site-packages/django/db/backends/mysql/schema.py"", line 31, in quote_value
    quoted = quoted.decode()
AttributeError: 'str' object has no attribute 'decode'
}}}

This is because of the quote_value method calling `decode()` on a string object (it is a method of a byte object). This doesn't happen when the migration is being applied, presumably, because then we're creating byte objects and the code doesn't trigger, but this is a guess."	Bug	closed	Database layer (models, ORM)	2.1	Release blocker	needsinfo	regression		Accepted	0	0	0	0	0	0
