Fixed #27615 -- Used timedeltas as arguments to Oracle database driver.

Removed unused DatabaseFeatures.driver_supports_timedeltas workaround.
This commit is contained in:
Mariusz Felisiak 2016-12-29 21:49:18 +01:00 committed by Tim Graham
parent fae56427e1
commit 7d14889aa3
4 changed files with 2 additions and 16 deletions

View File

@ -68,12 +68,6 @@ class BaseDatabaseFeatures(object):
# by returning the type used to store duration field? # by returning the type used to store duration field?
supports_temporal_subtraction = False supports_temporal_subtraction = False
# Does the database driver support timedeltas as arguments?
# This is only relevant when there is a native duration field.
# Specifically, there is a bug with cx_Oracle:
# https://bitbucket.org/anthony_tuininga/cx_oracle/issue/7/
driver_supports_timedelta_args = False
# Do time/datetime fields have microsecond precision? # Do time/datetime fields have microsecond precision?
supports_microsecond_precision = True supports_microsecond_precision = True

View File

@ -17,7 +17,6 @@ from django.db import utils
from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.base import BaseDatabaseWrapper
from django.utils import six, timezone from django.utils import six, timezone
from django.utils.deprecation import RemovedInDjango20Warning from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.duration import duration_string
from django.utils.encoding import force_bytes, force_text from django.utils.encoding import force_bytes, force_text
from django.utils.functional import cached_property from django.utils.functional import cached_property
@ -337,11 +336,6 @@ class OracleParam(object):
param = param.astimezone(timezone.utc).replace(tzinfo=None) param = param.astimezone(timezone.utc).replace(tzinfo=None)
param = Oracle_datetime.from_datetime(param) param = Oracle_datetime.from_datetime(param)
if isinstance(param, datetime.timedelta):
param = duration_string(param)
if ' ' not in param:
param = '0 ' + param
string_size = 0 string_size = 0
# Oracle doesn't recognize True and False correctly in Python 3. # Oracle doesn't recognize True and False correctly in Python 3.
# The conversion done below works both in 2 and 3. # The conversion done below works both in 2 and 3.
@ -351,7 +345,7 @@ class OracleParam(object):
param = 0 param = 0
if hasattr(param, 'bind_parameter'): if hasattr(param, 'bind_parameter'):
self.force_bytes = param.bind_parameter(cursor) self.force_bytes = param.bind_parameter(cursor)
elif isinstance(param, Database.Binary): elif isinstance(param, (Database.Binary, datetime.timedelta)):
self.force_bytes = param self.force_bytes = param
else: else:
# To transmit to the database, we need Unicode if supported # To transmit to the database, we need Unicode if supported

View File

@ -10,7 +10,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
has_real_datatype = True has_real_datatype = True
has_native_uuid_field = True has_native_uuid_field = True
has_native_duration_field = True has_native_duration_field = True
driver_supports_timedelta_args = True
can_defer_constraint_checks = True can_defer_constraint_checks = True
has_select_for_update = True has_select_for_update = True
has_select_for_update_nowait = True has_select_for_update_nowait = True

View File

@ -600,8 +600,7 @@ class Value(Expression):
class DurationValue(Value): class DurationValue(Value):
def as_sql(self, compiler, connection): def as_sql(self, compiler, connection):
connection.ops.check_expression_support(self) connection.ops.check_expression_support(self)
if (connection.features.has_native_duration_field and if connection.features.has_native_duration_field:
connection.features.driver_supports_timedelta_args):
return super(DurationValue, self).as_sql(compiler, connection) return super(DurationValue, self).as_sql(compiler, connection)
return connection.ops.date_interval_sql(self.value) return connection.ops.date_interval_sql(self.value)