mirror of
				https://github.com/django/django.git
				synced 2025-10-26 07:06:08 +00: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:
		| @@ -299,6 +299,10 @@ class DateTimeField(DateField): | |||||||
|     def get_db_prep_save(self, value): |     def get_db_prep_save(self, value): | ||||||
|         # Casts dates into string format for entry into database. |         # Casts dates into string format for entry into database. | ||||||
|         if value is not None: |         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) |             value = str(value) | ||||||
|         return Field.get_db_prep_save(self, value) |         return Field.get_db_prep_save(self, value) | ||||||
|  |  | ||||||
| @@ -493,6 +497,10 @@ class TimeField(Field): | |||||||
|     def get_db_prep_save(self, value): |     def get_db_prep_save(self, value): | ||||||
|         # Casts dates into string format for entry into database. |         # Casts dates into string format for entry into database. | ||||||
|         if value is not None: |         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) |             value = str(value) | ||||||
|         return Field.get_db_prep_save(self, value) |         return Field.get_db_prep_save(self, value) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user