]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fix oracle tests
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Jan 2011 03:37:18 +0000 (22:37 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Jan 2011 03:37:18 +0000 (22:37 -0500)
- fix some obnoxious type adaption issues resulting from the "adapt must copy" change

lib/sqlalchemy/types.py
test/orm/test_versioning.py
test/sql/test_types.py

index 1dcf379a956617b9313db632ff48056b1631d458..f9320cf3ebe65fcf5c27b93df049179b4485b9bd 100644 (file)
@@ -427,7 +427,7 @@ class TypeDecorator(TypeEngine):
 
         """
         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)
@@ -1785,7 +1785,11 @@ class Interval(_DateAffinity, TypeDecorator):
         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)
index a42b8e8fe2b3fdef58eaa84653ae4f47b1fc6206..128927d72759445b6e1e411ae7bb1431723ad18c 100644 (file)
@@ -465,7 +465,7 @@ class InheritanceTwoVersionIdsTest(_base.MappedTest):
     @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))
         )
index 1665e35c88b168ff44095e7907e01bd2c8941f33..e65f684c3a60220493193eae0bfc8deac1502127 100644 (file)
@@ -1506,6 +1506,13 @@ class IntervalTest(TestBase, AssertsExecutionResults):
     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")