[Django] #24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5

21 views
Skip to first unread message

Django

unread,
Apr 4, 2015, 4:50:34 PM4/4/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
----------------------------------------------+--------------------
Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
This combination does not support database microsecond precision.
Mircosecond precision was added to MySQL in version 5.6.4, but due to a
bug in older MySQLdb, is still not always available. See
https://github.com/farcepest/MySQLdb1/issues/24.

Before any changes, with this combination, when saving the date
`2008-12-31 23:59:59.999999` the database result is rounded to `2009-01-01
00:00:00`. However, (to my understanding) Django expects the date to be
truncated, not rounded.

Additionally, MySQL INTERVAL would promote a datetime without microseconds
to a datetime with microseconds if the INTERVAL was a float or contained
microseconds. Older MySQLdb was unable to properly parse the result to a
Python datetime.

FWIW, I ran into this using the system libraries of a default Fedora 21
install. Fedora 21 ships with following versions:

community-mysql-server-5.6.23-1.fc21.x86_64
MySQL-python-1.2.3-13.fc21.x86_64

Individuals can workaround this by using virtualenv to install a newer
MySQLdb or mysqlclient.

The following tests fail before any changes:

{{{
======================================================================
FAIL: test_mixed_type_annotation_date_interval
(annotations.tests.NonAggregateAnnotationTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jon/devel/django/tests/annotations/tests.py", line 147, in
test_mixed_type_annotation_date_interval
self.assertEqual(t.expires, expires)
AssertionError: None != datetime.datetime(2015, 3, 20, 15, 0)

======================================================================
FAIL: test_get_next_prev_by_field (model_regress.tests.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jon/devel/django/tests/model_regress/tests.py", line 178, in
test_get_next_prev_by_field
e.get_previous_by_when().when, datetime.datetime(2000, 1, 1, 6, 1, 1)
AssertionError: datetime.datetime(2000, 1, 1, 12, 0, 20) !=
datetime.datetime(2000, 1, 1, 6, 1, 1)

======================================================================
FAIL: test_mixed_comparisons1 (expressions.tests.FTimeDeltaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jon/devel/django/django/test/testcases.py", line 1023, in
skip_wrapper
return test_func(*args, **kwargs)
File "/home/jon/devel/django/tests/expressions/tests.py", line 765, in
test_mixed_comparisons1
self.assertEqual(test_set, self.expnames[:i + 1])
AssertionError: Lists differ: [] != [u'e0']

Second list contains 1 additional elements.
First extra element 0:
e0

- []
+ [u'e0']

======================================================================
FAIL: test_extra_method_select_argument_with_dashes_and_values
(basic.tests.ModelTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jon/devel/django/tests/basic/tests.py", line 304, in
test_extra_method_select_argument_with_dashes_and_values
[[('dashed-value', 1), ('headline', 'Article 11')], [('dashed-value',
1), ('headline', 'Article 12')]])
AssertionError: Lists differ: [[(u'dashed-value', 1L), (u'he... != [[(u
'dashed-value', 1), (u'hea...

Second list contains 1 additional elements.
First extra element 1:
[(u'dashed-value', 1), (u'headline', u'Article 12')]

- [[(u'dashed-value', 1L), (u'headline', u'Article 11')]]
? - ^

+ [[(u'dashed-value', 1), (u'headline', u'Article 11')],
? ^

+ [(u'dashed-value', 1), (u'headline', u'Article 12')]]

======================================================================
FAIL: test_year_lookup_edge_case (basic.tests.ModelTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jon/devel/django/tests/basic/tests.py", line 236, in
test_year_lookup_edge_case
["<Article: Article 11>", "<Article: Article 12>"])
File "/home/jon/devel/django/django/test/testcases.py", line 901, in
assertQuerysetEqual
return self.assertEqual(list(items), values, msg=msg)
AssertionError: Lists differ: ['<Article: Article 11>'] != [u'<Article:
Article 11>', u'<...

Second list contains 1 additional elements.
First extra element 1:
<Article: Article 12>

- ['<Article: Article 11>']
+ [u'<Article: Article 11>', u'<Article: Article 12>']

----------------------------------------------------------------------
}}}

PR to follow.

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

Django

unread,
Apr 4, 2015, 4:58:09 PM4/4/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jdufresne):

* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_tests: => 0
* needs_docs: => 0


Comment:

https://github.com/django/django/pull/4453

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

Django

unread,
Apr 4, 2015, 5:41:11 PM4/4/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by claudep):

Can you look at [9e746c13e81241fbf1ae64ec118edaa491790046] and see if
partially reverting that patch (stripping microseconds based on
`connection.features.supports_microsecond_precision`) does the job?
If we could prevent touching to `get_prep_value`, it would be better.

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

Django

unread,
Apr 4, 2015, 7:58:32 PM4/4/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by jdufresne):

Thanks!

I have updated the patch based on your suggestion.

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

Django

unread,
Apr 4, 2015, 8:08:01 PM4/4/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
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 timgraham):

* stage: Unreviewed => Accepted


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

Django

unread,
Apr 5, 2015, 3:11:15 PM4/5/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
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 claudep):

* stage: Accepted => Ready for checkin


Comment:

Thanks Jon, the patch looks good!
Tim, are you OK for backporting (considering current test failures with
this specific MySQL/MySQLdb combination)?

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

Django

unread,
Apr 6, 2015, 8:11:53 AM4/6/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
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
-------------------------------------+-------------------------------------

Comment (by timgraham):

Yes, backport is fine with me. Let's add release notes, of course.

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

Django

unread,
Apr 6, 2015, 11:05:21 AM4/6/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------

Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
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
-------------------------------------+-------------------------------------

Comment (by jdufresne):

Release notes added to PR. Thanks.

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

Django

unread,
Apr 6, 2015, 4:44:38 PM4/6/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody
Type: Bug | Status: closed

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:"2cf58e80d1be46ae95f77c95fe014921742295dd" 2cf58e8]:
{{{
#!CommitTicketReference repository=""
revision="2cf58e80d1be46ae95f77c95fe014921742295dd"
Fixed #24584 -- Fixed microsecond handling with older MySQLdb
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24584#comment:8>

Django

unread,
Apr 6, 2015, 4:46:15 PM4/6/15
to django-...@googlegroups.com
#24584: Test failures with MySQL >= 5.6.4 and MySQLdb < 1.2.5
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: closed
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
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"551d4bb46a3db7afed2d9bab4b27628a0a44b0fc" 551d4bb4]:
{{{
#!CommitTicketReference repository=""
revision="551d4bb46a3db7afed2d9bab4b27628a0a44b0fc"
[1.8.x] Fixed #24584 -- Fixed microsecond handling with older MySQLdb

Backport of 2cf58e80d from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24584#comment:9>

Reply all
Reply to author
Forward
0 new messages