Skip to content

Commit fb981ba

Browse files
authored
Merge pull request #204 from dhashe/fix-rows-affected
Don't display rows affected when the connector tells us -1
2 parents 4bd4234 + ad2d350 commit fb981ba

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## TBD
2+
3+
### Bug Fixes
4+
5+
* Fix [misleading "0 rows affected" status for CTEs](https://github.com/dbcli/litecli/issues/203)
6+
by never displaying rows affected when the connector tells us -1
7+
18
## 1.14.2 - 2025-01-26
29

310
### Bug Fixes

litecli/sqlexecute.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,19 @@ def get_result(self, cursor):
138138
# e.g. SELECT.
139139
if cursor.description is not None:
140140
headers = [x[0] for x in cursor.description]
141-
status = "{0} row{1} in set"
141+
status = "{count} row{s} in set"
142142
cursor = list(cursor)
143143
rowcount = len(cursor)
144144
else:
145145
_logger.debug("No rows in result.")
146-
status = "Query OK, {0} row{1} affected"
147-
rowcount = 0 if cursor.rowcount == -1 else cursor.rowcount
146+
if cursor.rowcount == -1:
147+
status = "Query OK"
148+
else:
149+
status = "Query OK, {count} row{s} affected"
150+
rowcount = cursor.rowcount
148151
cursor = None
149152

150-
status = status.format(rowcount, "" if rowcount == 1 else "s")
153+
status = status.format(count=rowcount, s="" if rowcount == 1 else "s")
151154

152155
return (title, cursor, headers, status)
153156

0 commit comments

Comments
 (0)