Skip to content

Conversation

@rolandwalker
Copy link
Contributor

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".
  • 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.
  • 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 from 64652ca to 94f4ec9 Compare December 29, 2025 23:22
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.
 * 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 94f4ec9 to 8e87ae9 Compare December 30, 2025 00: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