[Django] #26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+ warning

67 views
Skip to first unread message

Django

unread,
Jan 26, 2016, 9:58:38 AM1/26/16
to django-...@googlegroups.com
#26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+
warning
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
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 |
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26140>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 26, 2016, 3:53:42 PM1/26/16
to django-...@googlegroups.com
#26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+
warning
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/26140#comment:1>

Django

unread,
Jan 26, 2016, 6:55:36 PM1/26/16
to django-...@googlegroups.com
#26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+
warning
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by tinycogio):

* cc: giovanni@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/26140#comment:2>

Django

unread,
Feb 1, 2016, 4:45:12 AM2/1/16
to django-...@googlegroups.com
#26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+
warning
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by guilhem-bichot):

* cc: guilhem.bichot@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/26140#comment:3>

Django

unread,
Feb 13, 2016, 2:43:28 PM2/13/16
to django-...@googlegroups.com
#26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+
warning
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by claudep):

[https://github.com/django/django/pull/6140 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/26140#comment:4>

Django

unread,
Feb 13, 2016, 2:43:36 PM2/13/16
to django-...@googlegroups.com
#26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+
warning
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26140#comment:5>

Django

unread,
Mar 8, 2016, 12:45:04 PM3/8/16
to django-...@googlegroups.com
#26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+
warning
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/26140#comment:6>

Django

unread,
Mar 14, 2016, 1:09:37 PM3/14/16
to django-...@googlegroups.com
#26140: BinaryField value must be declared "binary" in queries to avoid MySQL 5.7+
warning
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"204e00c0c57c34528157a739389b6935e4af2f36" 204e00c0]:
{{{
#!CommitTicketReference repository=""
revision="204e00c0c57c34528157a739389b6935e4af2f36"
Fixed #26140 -- Suppressed MySQL warning when inserting binary content

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26140#comment:7>

Reply all
Reply to author
Forward
0 new messages