- fix some obnoxious type adaption issues resulting from the "adapt must copy" change
"""
adapted = dialect.type_descriptor(self)
- if adapted is not self:
+ if type(adapted) is not type(self):
return adapted
elif isinstance(self.impl, TypeDecorator):
return self.impl.type_engine(dialect)
if self.native and hasattr(cls, '_adapt_from_generic_interval'):
return cls._adapt_from_generic_interval(self, **kw)
else:
- return cls(**kw)
+ return self.__class__(
+ native=self.native,
+ second_precision=self.second_precision,
+ day_precision=self.day_precision,
+ **kw)
def bind_processor(self, dialect):
impl_processor = self.impl.bind_processor(dialect)
@classmethod
def define_tables(cls, metadata):
Table('base', metadata,
- Column('id', Integer, primary_key=True),
+ Column('id', Integer, primary_key=True, test_needs_autoincrement=True),
Column('version_id', Integer, nullable=True),
Column('data', String(50))
)
def teardown_class(cls):
metadata.drop_all()
+ def test_non_native_adapt(self):
+ interval = Interval(native=False)
+ adapted = interval.dialect_impl(testing.db.dialect)
+ assert type(adapted) is Interval
+ assert adapted.native is False
+ eq_(str(adapted), "DATETIME")
+
@testing.fails_on("+pg8000", "Not yet known how to pass values of the INTERVAL type")
@testing.fails_on("postgresql+zxjdbc", "Not yet known how to pass values of the INTERVAL type")
@testing.fails_on("oracle+zxjdbc", "Not yet known how to pass values of the INTERVAL type")