1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

[boulder-oracle-sprint] Avoided string conversion for DateTimeField in oracle

git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4008 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Boulder Sprinters 2006-11-05 00:13:09 +00:00
parent 8b1f56d06b
commit a12bdeb445

View File

@ -502,14 +502,17 @@ class DateTimeField(DateField):
# doesn't support microseconds.
if (settings.DATABASE_ENGINE == 'mysql' or settings.DATABASE_ENGINE=='oracle') and hasattr(value, 'microsecond'):
value = value.replace(microsecond=0)
# cx_Oracle wants the raw datetime instead of a string
if settings.DATABASE_ENGINE != 'oracle':
value = str(value)
elif isinstance(value, datetime.date):
# MySQL/Oracle will throw a warning if microseconds are given, because it
# doesn't support microseconds.
if (settings.DATABASE_ENGINE == 'mysql' or settings.DATABASE_ENGINE=='oracle') and hasattr(value, 'microsecond'):
value = datetime.datetime(value.year, value.month, value.day, microsecond=0)
# cx_Oracle wants the raw datetime instead of a string
if settings.DATABASE_ENGINE != 'oracle':
value = str(value)
return Field.get_db_prep_save(self, value)
def get_db_prep_lookup(self, lookup_type, value):