diff --git a/datasette/database.py b/datasette/database.py index 9641ae32..0a32442c 100644 --- a/datasette/database.py +++ b/datasette/database.py @@ -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) diff --git a/tests/test_internals_database.py b/tests/test_internals_database.py index 1df1d947..c167ac9c 100644 --- a/tests/test_internals_database.py +++ b/tests/test_internals_database.py @@ -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 diff --git a/tests/test_queries.py b/tests/test_queries.py index 7aa9883b..d6d1185b 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -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) ]