"Incorrect string value" warning when saving some unicode characters to MySQL
|Reported by:||denilsonsa||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
How to reproduce this bug, step-by-step:
- Create a new project.
- Create the database for this project in MySQL. Make sure the database has 'utf8' as its collation.
- Create a new app inside your project (here I'm calling it 'testapp'). Remember to add it to settings.py.
- At the models, create a simple one (I've named it TestModel) with just a CharField and/or a TextField.
- ./manage.py syncdb
- ./manage.py shell
- from testapp.models import TestModel
- Create a new instance of your model and set its attribute to u"Su\u1296it\U000f2a61\r\n"
- Call .save()
Boom! MySQLdb throws:
Warning: Incorrect string value: '\xF3\xB2\xA9\xA1\x0D\x0A' for column 'cf' at row 1
Please note that other unicode strings (like u'Bh\u0101skara\n') do work correctly, thus the MySQL database was set up correctly. However, that string above makes MySQLdb throw an exception.
Does the string above make any sense? I don't know, it was a piece of text copied-and-pasted by the user.
- Django 1.1.2
- MySQL 5.0.90
- mysql-python (MySQLdb) 1.2.3_rc1
- Python 2.6.5
Change History (3)
comment:1 Changed 5 years ago by kmtracey
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Resolution set to invalid
- Status changed from new to closed