Issue 87 in django-jython: No timezone support for MySQL

7 views
Skip to first unread message

django...@googlecode.com

unread,
Jan 18, 2015, 6:01:32 PM1/18/15
to django-j...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 87 by tedche...@gmail.com: No timezone support for MySQL
https://code.google.com/p/django-jython/issues/detail?id=87

What steps will reproduce the problem?
1. A model with datetime field
2. Django settings has USE_TZ = True
3. Save the object with a time-zone aware datetime into the MySQL database
3. Retrieve the object from the MySQL database.

The following testcase fails (added to tests.py, and after changing the
test database to use mysql)

from django.utils import timezone
from django.conf import settings

def test_datetime(self):
test_model = TestModel(field_4 = 'abc', field_6 = timezone.now())
test_model.save()
self.assertEqual(TestModel.objects.filter(field_4='abc').count(), 1)
obj = TestModel.objects.filter(field_4='abc')[0]
if settings.USE_TZ:
self.assertTrue(timezone.is_aware(obj.field_6))
else:
self.assertFalse(timezone.is_aware(obj.field_6))

What is the expected output? What do you see instead?
Expected a time-zone aware datetime object, but got a naive one instead.

What version of the product are you using? On what operating system?
django-jython: 1.7.0b2
jython: 2.7b4
django: 1.7.3
OS: Linux

Please provide any additional information below.
SQLite seems to work fine with timezone aware objects, but not MySQL.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

django...@googlecode.com

unread,
Feb 1, 2015, 3:34:43 PM2/1/15
to django-j...@googlegroups.com

Comment #1 on issue 87 by tedche...@gmail.com: No timezone support for MySQL
https://code.google.com/p/django-jython/issues/detail?id=87

I've created a patch for this which seems to fix this issue.

Attachments:
mysql-timezone0001.patch 3.8 KB
Reply all
Reply to author
Forward
0 new messages