Ticket #27615: 27615.diff

File 27615.diff, 2.8 KB (added by Tim Graham, 7 years ago)
  • django/db/backends/base/features.py

    diff --git a/django/db/backends/base/features.py b/django/db/backends/base/features.py
    index d749173..46ad9dc 100644
    a b class BaseDatabaseFeatures(object):  
    6868    # by returning the type used to store duration field?
    6969    supports_temporal_subtraction = False
    7070
    71     # Does the database driver support timedeltas as arguments?
    72     # This is only relevant when there is a native duration field.
    73     # Specifically, there is a bug with cx_Oracle:
    74     # https://bitbucket.org/anthony_tuininga/cx_oracle/issue/7/
    75     driver_supports_timedelta_args = False
    76 
    7771    # Do time/datetime fields have microsecond precision?
    7872    supports_microsecond_precision = True
    7973
  • django/db/backends/oracle/base.py

    diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
    index 2e6f02c..dd60cc6 100644
    a b class OracleParam(object):  
    344344                param = param.astimezone(timezone.utc).replace(tzinfo=None)
    345345            param = Oracle_datetime.from_datetime(param)
    346346
    347         if isinstance(param, datetime.timedelta):
    348             param = duration_string(param)
    349             if ' ' not in param:
    350                 param = '0 ' + param
    351 
    352347        string_size = 0
    353348        # Oracle doesn't recognize True and False correctly in Python 3.
    354349        # The conversion done below works both in 2 and 3.
  • django/db/backends/oracle/operations.py

    diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py
    index b800339..0d235ff 100644
    a b WHEN (new.%(col_name)s IS NULL)  
    9797        """
    9898        return "NUMTODSINTERVAL(%06f, 'SECOND')" % (timedelta.total_seconds()), []
    9999
     100    def format_for_duration_arithmetic(self, sql):
     101        return "NUMTODSINTERVAL(%s / 1000000, 'SECOND')" % sql
     102
    100103    def date_trunc_sql(self, lookup_type, field_name):
    101104        # http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions230.htm#i1002084
    102105        if lookup_type in ('year', 'month'):
  • django/db/models/expressions.py

    diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
    index 5c137ed..3add089 100644
    a b class Value(Expression):  
    600600class DurationValue(Value):
    601601    def as_sql(self, compiler, connection):
    602602        connection.ops.check_expression_support(self)
    603         if (connection.features.has_native_duration_field and
    604                 connection.features.driver_supports_timedelta_args):
     603        if connection.features.has_native_duration_field:
    605604            return super(DurationValue, self).as_sql(compiler, connection)
    606605        return connection.ops.date_interval_sql(self.value)
    607606
Back to Top