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:
parent
8b1f56d06b
commit
a12bdeb445
@ -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)
|
||||
value = str(value)
|
||||
# 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)
|
||||
value = str(value)
|
||||
|
||||
# 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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user