Opened 10 years ago
Closed 10 years ago
#26140 closed Cleanup/optimization (fixed)
BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+ warning
| Reported by: | Tim Graham | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | giovanni@…, guilhem.bichot@… | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
There are a couple warnings with running the Django test suite on MySQL 5.7:
test_json_serializer (serializers.test_data.SerializerDataTests) ... /media/sf_django/django/db/backends/mysql/base.py:112: Warning: Invalid utf8 character string: 'FD00' return self.cursor.execute(query, args) test_set_and_retrieve (model_fields.tests.BinaryFieldTests) ... /media/sf_django/django/db/backends/mysql/base.py:112: Warning: Invalid utf8 character string: 'FE'
I think these are both fixed by changing our queries from something like
cursor.execute("""
INSERT INTO `field` (binary)
VALUES (%s)
""", data)
to:
cursor.execute("""
INSERT INTO `field` (binary)
VALUES (_binary %s)
""", data)
The "_binary" tells MySQL that the following string is to be interpreted as binary, not to be interpreted/validated as utf8.
http://dev.mysql.com/doc/refman/5.7/en/charset-literal.html
There's some background in #26139.
Change History (7)
comment:1 by , 10 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 10 years ago
| Cc: | added |
|---|
comment:3 by , 10 years ago
| Cc: | added |
|---|
comment:4 by , 10 years ago
comment:5 by , 10 years ago
| Has patch: | set |
|---|
comment:6 by , 10 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Note:
See TracTickets
for help on using tickets.
PR