Merge branch 'meihkv-master'

pull/214/head
Catherine Devlin 2022-06-11 10:57:25 -05:00
commit 24f13561f4
3 changed files with 11 additions and 2 deletions

View File

@ -425,6 +425,7 @@ Credits
- Lucas Zeer for multi-line bugfixes for var substitution, ``<<``
- vkk800 for ``--file``
- Jens Albrecht for MySQL DatabaseError bugfix
- meihkv for connection-closing bugfix
.. _Distribute: http://pypi.python.org/pypi/distribute
.. _Buildout: http://www.buildout.org/

View File

@ -101,7 +101,8 @@ class Connection(object):
template = " {}"
result.append(template.format(engine_url.__repr__()))
return "\n".join(result)
@classmethod
def _close(cls, descriptor):
if isinstance(descriptor, Connection):
conn = descriptor
@ -114,7 +115,6 @@ class Connection(object):
"Could not close connection because it was not found amongst these: %s"
% str(cls.connections.keys())
)
cls.connections.pop(conn.name)
cls.connections.pop(str(conn.metadata.bind.url))
conn.session.close()

View File

@ -370,6 +370,7 @@ def test_multiline_bracket_var_substitution(ip):
""",
)
assert not result
def test_json_in_select(ip):
# Variable expansion does not work within json, but
@ -387,3 +388,10 @@ def test_json_in_select(ip):
)
assert ('{"greeting": "Farewell sweet {person}"}',)
def test_close_connection(ip):
connections = runsql(ip, "%sql -l")
connection_name = list(connections)[0]
runsql(ip, f"%sql -x {connection_name}")
connections_afterward = runsql(ip, "%sql -l")
assert connection_name not in connections_afterward