Fixed issue where the ``INTERVAL`` datatype on PostgreSQL and Oracle would
produce an ``AttributeError`` when used in the context of a comparison
operation against a ``timedelta()`` object. Pull request courtesy
MajorDallas.
Fixes: #6649
Closes: #6650
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6650
Pull-request-sha:
dd217a975e5f0d3157e81c731791225b6a32889f
Change-Id: I773caf2673294fdb3c92b42895ad714e944d1bf8
--- /dev/null
+.. change::
+ :tags: bug, postgresql, oracle
+ :tickets: 6649
+
+ Fixed issue where the ``INTERVAL`` datatype on PostgreSQL and Oracle would
+ produce an ``AttributeError`` when used in the context of a comparison
+ operation against a ``timedelta()`` object. Pull request courtesy
+ MajorDallas.
day_precision=self.day_precision,
)
+ def coerce_compared_value(self, op, value):
+ return self
+
class ROWID(sqltypes.TypeEngine):
"""Oracle ROWID type.
def python_type(self):
return dt.timedelta
+ def coerce_compared_value(self, op, value):
+ return self
+
PGInterval = INTERVAL
def test_interval(self, type_, expected):
self.assert_compile(type_, expected)
+ def test_interval_coercion_literal(self):
+ expr = column("bar", oracle.INTERVAL) == datetime.timedelta(days=1)
+ eq_(expr.right.type._type_affinity, sqltypes.Interval)
+
class TypesTest(fixtures.TestBase):
__only_on__ = "oracle"
eq_(expr.type._type_affinity, types.Interval)
assert isinstance(expr.type, postgresql.INTERVAL)
+ def test_interval_coercion_literal(self):
+ expr = column("bar", postgresql.INTERVAL) == datetime.timedelta(days=1)
+ eq_(expr.right.type._type_affinity, types.Interval)
+
class SpecialTypesCompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = "postgresql"