Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't display rows affected when the connector tells us -1 #204

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## TBD

### Bug Fixes

* Fix [misleading "0 rows affected" status for CTEs](https://github.com/dbcli/litecli/issues/203)
by never displaying rows affected when the connector tells us -1

## 1.14.2 - 2025-01-26

### Bug Fixes
Expand Down
11 changes: 7 additions & 4 deletions litecli/sqlexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,19 @@ def get_result(self, cursor):
# e.g. SELECT.
if cursor.description is not None:
headers = [x[0] for x in cursor.description]
status = "{0} row{1} in set"
status = "{count} row{s} in set"
cursor = list(cursor)
rowcount = len(cursor)
else:
_logger.debug("No rows in result.")
status = "Query OK, {0} row{1} affected"
rowcount = 0 if cursor.rowcount == -1 else cursor.rowcount
if cursor.rowcount == -1:
status = "Query OK"
else:
status = "Query OK, {count} row{s} affected"
rowcount = cursor.rowcount
cursor = None

status = status.format(rowcount, "" if rowcount == 1 else "s")
status = status.format(count=rowcount, s="" if rowcount == 1 else "s")

return (title, cursor, headers, status)

Expand Down
Loading