diff --git a/changelog.md b/changelog.md index 6eb0c557..9f62f650 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +Upcoming (TBD) +============== + +Bug Fixes +--------- +* Watch command now returns correct time when ran as part of a multi-part query (#1565) + + 1.54.1 (2026/02/17) ============== diff --git a/mycli/main.py b/mycli/main.py index edc30d8f..c8350bd7 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -900,7 +900,7 @@ def show_suggestion_tip() -> bool: def output_res(results: Generator[SQLResult], start: float) -> None: nonlocal mutating - result_count = 0 + result_count = watch_count = 0 for result in results: title = result.title cur = result.results @@ -915,13 +915,15 @@ def output_res(results: Generator[SQLResult], start: float) -> None: # If this is a watch query, offset the start time on the 2nd+ iteration # to account for the sleep duration if command is not None and command["name"] == "watch": - if result_count > 0: + if watch_count > 0: try: watch_seconds = float(command["seconds"]) start += watch_seconds except ValueError as e: self.echo(f"Invalid watch sleep time provided ({e}).", err=True, fg="red") sys.exit(1) + else: + watch_count += 1 if is_select(status) and isinstance(cur, Cursor) and cur.rowcount > threshold: self.echo( f"The result set has more than {threshold} rows.",