Skip to content

Commit 432624c

Browse files
Merge pull request #907 from guzman-raphael/master
Fix issue with explicit calls to `dj.Connection`
2 parents aa1b563 + a9027f2 commit 432624c

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Release notes
22

3+
### 0.13.2 -- TBD
4+
* Bugfix - Explicit calls to `dj.Connection` throw error due to missing `host_input` (#895) PR #907
5+
36
### 0.13.1 -- Apr 16, 2021
47
* Add `None` as an alias for `IS NULL` comparison in `dict` restrictions (#824) PR #893
58
* Drop support for MySQL 5.6 since it has reached EOL PR #893

datajoint/connection.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def conn(host=None, user=None, password=None, *, init_fun=None, reset=False, use
107107
#encrypted-connection-options).
108108
"""
109109
if not hasattr(conn, 'connection') or reset:
110-
host_input = host if host is not None else config['database.host']
111-
host = get_host_hook(host_input)
110+
host = host if host is not None else config['database.host']
112111
user = user if user is not None else config['database.user']
113112
password = password if password is not None else config['database.password']
114113
if user is None: # pragma: no cover
@@ -117,8 +116,7 @@ def conn(host=None, user=None, password=None, *, init_fun=None, reset=False, use
117116
password = getpass(prompt="Please enter DataJoint password: ")
118117
init_fun = init_fun if init_fun is not None else config['connection.init_function']
119118
use_tls = use_tls if use_tls is not None else config['database.use_tls']
120-
conn.connection = Connection(host, user, password, None, init_fun, use_tls,
121-
host_input=host_input)
119+
conn.connection = Connection(host, user, password, None, init_fun, use_tls)
122120
return conn.connection
123121

124122

@@ -160,8 +158,8 @@ class Connection:
160158
:param use_tls: TLS encryption option
161159
"""
162160

163-
def __init__(self, host, user, password, port=None, init_fun=None, use_tls=None,
164-
host_input=None):
161+
def __init__(self, host, user, password, port=None, init_fun=None, use_tls=None):
162+
host_input, host = (host, get_host_hook(host))
165163
if ':' in host:
166164
# the port in the hostname overrides the port argument
167165
host, port = host.split(':')

docs-parts/intro/Releases_lang1.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.13.2 -- TBD
2+
-------------
3+
* Bugfix - Explicit calls to `dj.Connection` throw error due to missing `host_input` (#895) PR #907
4+
15
0.13.1 -- Apr 16, 2021
26
----------------------
37
* Add `None` as an alias for `IS NULL` comparison in `dict` restrictions (#824) PR #893

tests/test_connection.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ def test_dj_conn():
1717
assert_true(c.is_connected)
1818

1919

20+
def test_dj_connection_class():
21+
"""
22+
Should be able to establish a connection
23+
"""
24+
c = dj.Connection(**CONN_INFO)
25+
assert_true(c.is_connected)
26+
27+
2028
def test_persistent_dj_conn():
2129
"""
2230
conn() method should provide persistent connection across calls.

0 commit comments

Comments
 (0)