]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix TypeError during cx_Oracle connection
authorJohn Vandenberg <jayvdb@gmail.com>
Thu, 5 May 2016 13:26:00 +0000 (09:26 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 16 May 2016 14:15:19 +0000 (10:15 -0400)
cx_Oracle connection parameters user, password and dsn must be
either a string or NULL.  When they are passed a Python None object,
"TypeError: expecting string, unicode or buffer object" is raised.

Fixes: #3705
Change-Id: I8da5d8a227ca12c9bf17a6127460e413841951fb
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/271

doc/build/changelog/changelog_10.rst
lib/sqlalchemy/dialects/oracle/cx_oracle.py

index 30f8fb73e0c5528a8579c8e61448aca9ffa4f7a7..972e808dfa74a7d55dd434eb77625ff8679a8d0d 100644 (file)
         :meth:`.Query.group_by` method would raise an error, instead
         of intepreting the object as a SQL fragment.
 
+    .. change::
+        :tags: bug, oracle
+        :tickets: 3705
+
+        Fixed a bug in the cx_Oracle connect process that caused a TypeError
+        when the either the user, password or dsn was empty. This prevented
+        external authentication to Oracle databases, and prevented connecting
+        to the default dsn.  The connect string oracle:// now logs into the
+        default dsn using the Operating System username, equivalent to
+        connecting using '/' with sqlplus.
+
     .. change::
         :tags: bug, oracle
         :tickets: 3699
index 0c93ced97ddfc6ab54239fc9bf192489c6c4b70b..cfd942d853f6886b02fea5d35177866c5728b186 100644 (file)
@@ -914,13 +914,17 @@ class OracleDialect_cx_oracle(OracleDialect):
             dsn = url.host
 
         opts = dict(
-            user=url.username,
-            password=url.password,
-            dsn=dsn,
             threaded=self.threaded,
             twophase=self.allow_twophase,
         )
 
+        if dsn is not None:
+            opts['dsn'] = dsn
+        if url.password is not None:
+            opts['password'] = url.password
+        if url.username is not None:
+            opts['user'] = url.username
+
         if util.py2k:
             if self._cx_oracle_with_unicode:
                 for k, v in opts.items():