]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- removed problematic generate_dbapi_typemap() method. its hardcoded just for oracle
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 26 Jul 2007 22:30:09 +0000 (22:30 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 26 Jul 2007 22:30:09 +0000 (22:30 +0000)
so far (which needs it the most).

lib/sqlalchemy/databases/oracle.py
lib/sqlalchemy/engine/default.py

index 3350a35068c2e409579aa4cf2b86adfc2ee50159..9d663f6ee4f903c5515926c933bbea87ee9f4c3f 100644 (file)
@@ -220,6 +220,19 @@ class OracleDialect(ansisql.ANSIDialect):
         else:
             self.ORACLE_BINARY_TYPES = []
 
+    def dbapi_type_map(self):
+        if self.dbapi is None:
+            return {}
+        else:
+            return {
+                dbapi.NUMBER: OracleInteger(), 
+                dbapi.CLOB: OracleText(), 
+                dbapi.BLOB: OracleBinary(), 
+                dbapi.STRING: OracleString(), 
+                dbapi.TIMESTAMP: OracleTimestamp(), 
+                dbapi.BINARY: OracleRaw(), 
+                datetime.datetime: OracleDate()
+            }
 
     def dbapi(cls):
         import cx_Oracle
index ff7a62eec0ee2591f62a2a34fc714b7bb955348b..962e2ab606da67b5dad817381627e696830e50c3 100644 (file)
@@ -21,28 +21,6 @@ class DefaultDialect(base.Dialect):
         self._ischema = None
         self.dbapi = dbapi
         self._figure_paramstyle(paramstyle=paramstyle, default=default_paramstyle)
-        self._generate_dbapi_type_map()
-        
-    def _generate_dbapi_type_map(self):
-        """locate all TypeEngine objects in the dialect's module and map them against the DBAPI
-        type they represent.
-        
-        TODO: dialects should export this mapping explicitly, instead of relying upon
-        module searching.
-
-        TODO: so far, this only seems to work with oracle
-        """
-        dialect_module = sys.modules[self.__class__.__module__]
-        map = {}
-        if False:
-            for obj in dialect_module.__dict__.values():
-                if self.dbapi is not None and isinstance(obj, type) and issubclass(obj, types.TypeEngine):
-                    obj = obj()
-                    try:
-                        map[obj.get_dbapi_type(self.dbapi)] = obj
-                    except AttributeError:
-                        pass
-        self._dbapi_type_map = map
     
     def decode_result_columnname(self, name):
         """decode a name found in cursor.description to a unicode object."""
@@ -50,7 +28,10 @@ class DefaultDialect(base.Dialect):
         return name.decode(self.encoding)
         
     def dbapi_type_map(self):
-        return self._dbapi_type_map
+        # most DBAPIs have problems with this (such as, psycocpg2 types 
+        # are unhashable).  So far Oracle can return it.
+        
+        return {}
             
     def create_execution_context(self, **kwargs):
         return DefaultExecutionContext(self, **kwargs)