From 8ccc894e17d3352c686cabd0f770ca86ff3ac1cf Mon Sep 17 00:00:00 2001 From: Boulder Sprinters Date: Wed, 16 May 2007 16:48:36 +0000 Subject: [PATCH] boulder-oracle-sprint: Removed obsolete stripping of microseconds from datetime objects. git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5260 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/__init__.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 0afd8471fd..7e36d4c340 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -535,18 +535,14 @@ 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/Oracle will throw a warning if microseconds are given, because - # neither database supports microseconds. - if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'): + # MySQL will throw a warning if microseconds are given, because it + # doesn't support microseconds. + if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): value = value.replace(microsecond=0) value = str(value) return Field.get_db_prep_save(self, value) def get_db_prep_lookup(self, lookup_type, value): - # Oracle will throw an error if microseconds are given, because it - # doesn't support microseconds. - if settings.DATABASE_ENGINE == 'oracle' and hasattr(value, 'microsecond'): - value = value.replace(microsecond=0) if lookup_type == 'range': value = [str(v) for v in value] else: @@ -846,12 +842,13 @@ class TimeField(Field): if value is not None: # MySQL will throw a warning if microseconds are given, because it # doesn't support microseconds. - if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'): + if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): value = value.replace(microsecond=0) - if settings.DATABASE_ENGINE == 'oracle': + elif settings.DATABASE_ENGINE == 'oracle': # cx_Oracle expects a datetime.datetime to persist into TIMESTAMP field. if isinstance(value, datetime.time): - value = datetime.datetime(1900, 1, 1, value.hour, value.minute, value.second) + value = datetime.datetime(1900, 1, 1, value.hour, value.minute, + value.second, value.microsecond) elif isinstance(value, basestring): value = datetime.datetime(*(time.strptime(value, '%H:%M:%S')[:6])) else: