mirror of
https://github.com/simonw/datasette.git
synced 2026-06-14 21:16:56 +02:00
Fixed an edge case with exactly 11 results returned
We select 11 when we return 10 just to detect if the results were truncated. We were returning rowcount: 11 in this case when it should have been -1.
This commit is contained in:
parent
c9e5115044
commit
b4761bab53
3 changed files with 4 additions and 4 deletions
|
|
@ -920,7 +920,7 @@ class ExecuteWriteResult:
|
|||
rowcount = cursor.rowcount
|
||||
finally:
|
||||
cursor.close()
|
||||
if description is not None and not return_all and truncated and rowcount == 0:
|
||||
if description is not None and not return_all and truncated:
|
||||
rowcount = -1
|
||||
return cls(rowcount, lastrowid, description, rows, truncated)
|
||||
|
||||
|
|
|
|||
|
|
@ -576,7 +576,7 @@ async def test_execute_write_with_returning_one_more_than_default_limit(db):
|
|||
"update write_returning_one_more set id = id returning id"
|
||||
)
|
||||
|
||||
assert result.rowcount == 11
|
||||
assert result.rowcount == -1
|
||||
assert result.truncated is True
|
||||
assert len(result.fetchall()) == 10
|
||||
|
||||
|
|
|
|||
|
|
@ -1941,8 +1941,8 @@ async def test_execute_write_json_returning_rows_can_be_truncated():
|
|||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["ok"] is True
|
||||
assert data["message"] == "Query executed, 11 rows affected"
|
||||
assert data["rowcount"] == 11
|
||||
assert data["message"] == "Query executed"
|
||||
assert data["rowcount"] == -1
|
||||
assert data["rows"] == [
|
||||
{"id": index, "name": "Dog {}!".format(index)} for index in range(1, 11)
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue