Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #316 -- Added special-case for MySQL microseconds, so that it d…

…oesn't throw a warning when microseconds are given.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@497 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit bc00059b2fcc4e59c2bef59700a8a78a3e014948 1 parent 2c3067b
Adrian Holovaty authored August 15, 2005

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. 8  django/core/meta/fields.py
8  django/core/meta/fields.py
@@ -299,6 +299,10 @@ class DateTimeField(DateField):
299 299
     def get_db_prep_save(self, value):
300 300
         # Casts dates into string format for entry into database.
301 301
         if value is not None:
  302
+            # MySQL will throw a warning if microseconds are given, because it
  303
+            # doesn't support microseconds.
  304
+            if settings.DATABASE_ENGINE == 'mysql':
  305
+                value = value.replace(microsecond=0)
302 306
             value = str(value)
303 307
         return Field.get_db_prep_save(self, value)
304 308
 
@@ -493,6 +497,10 @@ def pre_save(self, value, add):
493 497
     def get_db_prep_save(self, value):
494 498
         # Casts dates into string format for entry into database.
495 499
         if value is not None:
  500
+            # MySQL will throw a warning if microseconds are given, because it
  501
+            # doesn't support microseconds.
  502
+            if settings.DATABASE_ENGINE == 'mysql':
  503
+                value = value.replace(microsecond=0)
496 504
             value = str(value)
497 505
         return Field.get_db_prep_save(self, value)
498 506
 

0 notes on commit bc00059

Please sign in to comment.
Something went wrong with that request. Please try again.