second_precision=interval.second_precision,
)
+ @classmethod
+ def adapt_emulated_to_native(
+ cls, interval: sqltypes.Interval, **kw # type: ignore[override]
+ ):
+ return INTERVAL(
+ day_precision=interval.day_precision,
+ second_precision=interval.second_precision,
+ )
+
@property
def _type_affinity(self):
return sqltypes.Interval
"""A type for ``datetime.timedelta()`` objects.
The Interval type deals with ``datetime.timedelta`` objects. In
- PostgreSQL, the native ``INTERVAL`` type is used; for others, the
- value is stored as a date which is relative to the "epoch"
+ PostgreSQL and Oracle, the native ``INTERVAL`` type is used; for others,
+ the value is stored as a date which is relative to the "epoch"
(Jan. 1, 1970).
Note that the ``Interval`` type does not currently provide date arithmetic
oracle.INTERVAL(day_precision=2, second_precision=5),
"INTERVAL DAY(2) TO SECOND(5)",
),
+ (
+ sqltypes.Interval(day_precision=9, second_precision=3),
+ "INTERVAL DAY(9) TO SECOND(3)",
+ ),
)
def test_interval(self, type_, expected):
self.assert_compile(type_, expected)