1
0
mirror of https://github.com/django/django.git synced 2025-07-05 02:09:13 +00:00

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
This commit is contained in:
Boulder Sprinters 2007-05-16 16:48:36 +00:00
parent 786782edc5
commit 8ccc894e17

View File

@ -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: