summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-05-16 16:48:36 +0000
committerBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-05-16 16:48:36 +0000
commit8ccc894e17d3352c686cabd0f770ca86ff3ac1cf (patch)
tree0a94a28ec7f0868d8abe72d39b4b5359a8ea5c56
parent786782edc5300421b5f86de9d687c931dd21d14b (diff)
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
-rw-r--r--django/db/models/fields/__init__.py17
1 files 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: