Skip to content

Commit 502fd1e

Browse files
committed
BUG29324966: Add missing username connection argument for driver compatibility
This patch adds the missing username connection argument as an alias of the user in the classic connector. Test was added for regression.
1 parent c571c33 commit 502fd1e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/mysql/connector/abstracts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def config(self, **kwargs):
276276
compat_map = [
277277
# (<other driver argument>,<translates to>)
278278
('db', 'database'),
279+
('username', 'user'),
279280
('passwd', 'password'),
280281
('connect_timeout', 'connection_timeout'),
281282
]

tests/test_bugs.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5626,3 +5626,30 @@ def test_retrieve_from_LONGBLOB(self):
56265626

56275627
cur.close()
56285628
cnx.close()
5629+
5630+
5631+
class BugOra29324966(tests.MySQLConnectorTests):
5632+
"""BUG#29324966: ADD MISSING USERNAME CONNECTION ARGUMENT FOR DRIVER
5633+
COMPATIBILITY.
5634+
"""
5635+
def setUp(self):
5636+
pass
5637+
5638+
def tearDown(self):
5639+
pass
5640+
5641+
@foreach_cnx()
5642+
def test_connection_args_compatibility(self):
5643+
config = self.config.copy()
5644+
config["username"] = config["user"]
5645+
config["passwd"] = config["password"]
5646+
config["db"] = config["database"]
5647+
config["connect_timeout"] = config["connection_timeout"]
5648+
5649+
config.pop("user")
5650+
config.pop("password")
5651+
config.pop("database")
5652+
config.pop("connection_timeout")
5653+
5654+
cnx = self.cnx.__class__(**config)
5655+
cnx.close()

0 commit comments

Comments
 (0)