From bc00059b2fcc4e59c2bef59700a8a78a3e014948 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 15 Aug 2005 01:03:39 +0000 Subject: [PATCH] Fixed #316 -- Added special-case for MySQL microseconds, so that it doesn't throw a warning when microseconds are given. git-svn-id: http://code.djangoproject.com/svn/django/trunk@497 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/meta/fields.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py index 6743ed79a9..87b5a34fa0 100644 --- a/django/core/meta/fields.py +++ b/django/core/meta/fields.py @@ -299,6 +299,10 @@ class DateTimeField(DateField): def get_db_prep_save(self, value): # Casts dates into string format for entry into database. if value is not None: + # MySQL will throw a warning if microseconds are given, because it + # doesn't support microseconds. + if settings.DATABASE_ENGINE == 'mysql': + value = value.replace(microsecond=0) value = str(value) return Field.get_db_prep_save(self, value) @@ -493,6 +497,10 @@ class TimeField(Field): def get_db_prep_save(self, value): # Casts dates into string format for entry into database. if value is not None: + # MySQL will throw a warning if microseconds are given, because it + # doesn't support microseconds. + if settings.DATABASE_ENGINE == 'mysql': + value = value.replace(microsecond=0) value = str(value) return Field.get_db_prep_save(self, value)