Skip to content

Commit 9b04391

Browse files
author
erdenezul
authored
Merge pull request #1736 from vainu-arto/register-connection-match-connection
Add db parameter to register_connection #606
2 parents 326fcf4 + 8f6c079 commit 9b04391

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dev
99
- Improve LazyReferenceField and GenericLazyReferenceField with nested fields #1704
1010
- Fix validation error instance in GenericEmbeddedDocumentField #1067
1111
- Update cached fields when fields argument is given #1712
12+
- Add a db parameter to register_connection for compatibility with connect
1213

1314
Changes in 0.15.0
1415
=================

mongoengine/connection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MongoEngineConnectionError(Exception):
2828
_dbs = {}
2929

3030

31-
def register_connection(alias, name=None, host=None, port=None,
31+
def register_connection(alias, db=None, name=None, host=None, port=None,
3232
read_preference=READ_PREFERENCE,
3333
username=None, password=None,
3434
authentication_source=None,
@@ -39,6 +39,7 @@ def register_connection(alias, name=None, host=None, port=None,
3939
:param alias: the name that will be used to refer to this connection
4040
throughout MongoEngine
4141
:param name: the name of the specific database to use
42+
:param db: the name of the database to use, for compatibility with connect
4243
:param host: the host name of the :program:`mongod` instance to connect to
4344
:param port: the port that the :program:`mongod` instance is running on
4445
:param read_preference: The read preference for the collection
@@ -58,7 +59,7 @@ def register_connection(alias, name=None, host=None, port=None,
5859
.. versionchanged:: 0.10.6 - added mongomock support
5960
"""
6061
conn_settings = {
61-
'name': name or 'test',
62+
'name': name or db or 'test',
6263
'host': host or 'localhost',
6364
'port': port or 27017,
6465
'read_preference': read_preference,

0 commit comments

Comments
 (0)