diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-08-15 01:03:39 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-08-15 01:03:39 +0000 |
| commit | bc00059b2fcc4e59c2bef59700a8a78a3e014948 (patch) | |
| tree | c4d128f88aba9fd8bf2cd527a6046ef40b47e67b | |
| parent | 2c3067b5e5c7f4a818337760c029267d8658eb0a (diff) | |
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
| -rw-r--r-- | django/core/meta/fields.py | 8 |
1 files changed, 8 insertions, 0 deletions
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) |
