Skip to content

Conversation

@rolandwalker
Copy link
Contributor

@rolandwalker rolandwalker commented Dec 29, 2025

Description

Followups to reconnect() refactor:

  • Before attempting sqlexecute.connect(), try ping(reconnect=True) to do a true reconnect, preserving the connection_id() and other state such as session variables. This is the important part, which the commentary calls the "second pass". But it may not have an effect in practice.
  • Also, before attempting ping(reconnect=True), try ping(reconnect=False) with fewer feedback messages, which the commentary calls the "first pass". This pass is helpful to keep chatter down when the user habitually chooses the "connect" verb over "use". Unlike the second pass, it definitely works in practice.
  • Add new explicit feedback around creating a new connection when doing so, including a red tip to the user that session state was lost, either in the second pass or the third pass.
  • Tweak docstring in manual_reconnect() eg: "real function" -> "utility method"
  • Move db-change logic out of utility method, into manual_reconnect() and change_db(), keeping the database optional argument, as it is still useful for finessing feedback messages.
  • Silently skip changing the database if it equals "``".
  • In the usual case, let manual_reconnect() yield the result of change_db(), leaving us directly hooked in to the 4-tuple return-value system (instead of iterating on change_db() internally and manually handling the echo()).
  • Add an assert on self.sqlexecute.conn before pinging it.
  • Clarify "database" vs "server" in reconnect() docstring. (Pedantically it could be "cluster" or "endpoint").
  • Update changelog, but just piggyback two words onto the previous entry.
  • Update tests to use mycli.packages.special.execute() rather than CliRunner(). CliRunner() is only capable of testing the first line of output, which is taken up by an initialization statement.

xref #1416

Checklist

  • I've added this contribution to the changelog.md.
  • I've added my name to the AUTHORS file (or it's already there).
  • I ran uv run ruff check && uv run ruff format && uv run mypy --install-types . to lint and format the code.

@rolandwalker rolandwalker self-assigned this Dec 29, 2025
@rolandwalker rolandwalker force-pushed the RW/reconnect-preserve-connection-id branch 6 times, most recently from ee417fa to c386174 Compare December 30, 2025 18:01
Followups to reconnect() refactor:
 * Before attempting sqlexecute.connect(), try ping(reconnect=True)
   to do a true reconnect, preserving the connection_id() and other
   state such as session variables.  This is the important part, which
   the commentary calls the "second pass".
 * Also, before attempting ping(reconnect=True), try
   ping(reconnect=False) with fewer feedback messages, which the
   commentary calls the "first pass".  This pass is helpful to keep
   chatter down when the user habitually chooses the "connect" verb over
   "use".
 * Add new explicit feedback around creating a new connection when doing
   so, including a red tip to the user that session state was lost,
   either in the second pass or the third pass.
 * Tweak docstring in manual_reconnect() eg: "real function" -> "utility
   method"
 * Move db-change logic out of utility method, into manual_reconnect()
   and change_db(), keeping the "database" optional argument, as it is
   still useful for finessing feedback messages.
 * Silently skip changing the database if it equals "``".
 * In the usual case, let manual_reconnect() yield the result of
   change_db(), leaving us directly hooked in to the 4-tuple return-
   value system (instead of iterating on change_db() internally and
   manually handling the echo()).
 * Add an assert on self.sqlexecute.conn before pinging it.
 * Clarify "database" vs "server" in reconnect() docstring.
   (Pedantically it could be "cluster" or "endpoint").
 * Update changelog, but just piggyback two words onto the previous
   entry.
 * Update tests to use mycli.packages.special.execute() rather than
   CliRunner().  CliRunner() is only capable of testing the first
   line of output, which is taken up by an initialization statement.
@rolandwalker rolandwalker force-pushed the RW/reconnect-preserve-connection-id branch from c386174 to 9c5c04c Compare December 30, 2025 18:24
@rolandwalker rolandwalker merged commit 015b491 into main Dec 30, 2025
8 checks passed
@rolandwalker rolandwalker deleted the RW/reconnect-preserve-connection-id branch December 30, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants