mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
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:
parent
2c3067b5e5
commit
bc00059b2f
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user