]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
adjust to allow mock DBAPIs
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 12 Mar 2010 21:49:32 +0000 (16:49 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 12 Mar 2010 21:49:32 +0000 (16:49 -0500)
lib/sqlalchemy/dialects/oracle/cx_oracle.py

index c5e24cbb35dbbcb02ed12cd1da149aeedb42171f..75e6cadf51c632c9da5bef7f5b4630818261eb57 100644 (file)
@@ -348,20 +348,23 @@ class Oracle_cx_oracle(OracleDialect):
             cx_oracle_ver = vers(self.dbapi.version)
             self.supports_unicode_binds = cx_oracle_ver >= (5, 0)
             self._cx_oracle_native_nvarchar = cx_oracle_ver >= (5, 0)
-           
-        if self.dbapi is not None and not hasattr(self.dbapi, 'UNICODE'):
-             # cx_Oracle WITH_UNICODE mode.  *only* python
-             # unicode objects accepted for anything
-             self._cx_oracle_string_types = set([self.dbapi.STRING])
-             self.supports_unicode_statements = True
-             self.supports_unicode_binds = True
-             self._cx_oracle_with_unicode = True
         else:
-             self._cx_oracle_with_unicode = False
-             if self.dbapi is not None:
-                 self._cx_oracle_string_types = set([self.dbapi.UNICODE, self.dbapi.STRING])
-             else:
-                 self._cx_oracle_string_types = set()
+            cx_oracle_ver = None
+            
+        if cx_oracle_ver is None:
+            # this occurs in tests with mock DBAPIs
+            self._cx_oracle_string_types = set()
+            self._cx_oracle_with_unicode = False
+        elif not hasattr(self.dbapi, 'UNICODE'):
+            # cx_Oracle WITH_UNICODE mode.  *only* python
+            # unicode objects accepted for anything
+            self._cx_oracle_string_types = set([self.dbapi.STRING])
+            self.supports_unicode_statements = True
+            self.supports_unicode_binds = True
+            self._cx_oracle_with_unicode = True
+        else:
+            self._cx_oracle_with_unicode = False
+            self._cx_oracle_string_types = set([self.dbapi.UNICODE, self.dbapi.STRING])
  
         if self.dbapi is None or \
                     not self.auto_convert_lobs or \