#30371: sqlmigrate fails with string defaults on mysql
-------------------------------------+-------------------------------------
Reporter: Melvyn | Owner: nobody
Sopacua |
Type: Bug | Status: new
Component: Database | Version: 2.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/30371>
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/049.509cc15bb68afb098a29b25ed690c30b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.