Skip to content

Commit becc670

Browse files
committed
avoid depending on a string match into host_info
property, in "status" output. Detecting the "unix_socket" property should be more robust.
1 parent 025f33e commit becc670

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Internal
1818
---------
1919
* Use prompt_toolkit's `bell()`.
2020
* Refactor `SQLResult` dataclass.
21+
* Avoid depending on string matches into host info.
2122

2223

2324
1.58.0 (2026/02/28)

mycli/packages/special/dbcommands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def status(cur: Cursor, **_) -> list[SQLResult]:
128128
output.append(("Protocol version:", variables["protocol_version"]))
129129
output.append(('SSL/TLS version:', get_ssl_version(cur)))
130130

131-
if getattr(cur.connection, 'unix_socket', None) is not None:
131+
if getattr(cur.connection, 'unix_socket', None):
132132
host_info = cur.connection.host_info
133133
else:
134134
host_info = f'{cur.connection.host} via TCP/IP'
@@ -147,10 +147,10 @@ def status(cur: Cursor, **_) -> list[SQLResult]:
147147
output.append(("Client characterset:", charset[2]))
148148
output.append(("Conn. characterset:", charset[3]))
149149

150-
if "TCP/IP" in host_info:
151-
output.append(("TCP port:", cur.connection.port))
150+
if getattr(cur.connection, 'unix_socket', None):
151+
output.append(('UNIX socket:', variables['socket']))
152152
else:
153-
output.append(("UNIX socket:", variables["socket"]))
153+
output.append(('TCP port:', cur.connection.port))
154154

155155
if "Uptime" in status:
156156
output.append(("Uptime:", format_uptime(status["Uptime"])))

0 commit comments

Comments
 (0)