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
This commit is contained in:
Adrian Holovaty 2005-08-15 01:03:39 +00:00
parent 2c3067b5e5
commit bc00059b2f
1 changed files with 8 additions and 0 deletions

View File

@ -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)