Skip to content

Commit

Permalink
Merge pull request #204 from dhashe/fix-rows-affected
Browse files Browse the repository at this point in the history
Don't display rows affected when the connector tells us -1
  • Loading branch information
amjith authored Jan 29, 2025
2 parents 4bd4234 + ad2d350 commit fb981ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit fb981ba

Please sign in to comment.