Expose count truncation in table JSON via count_truncated extra

The count extra is computed with a limit subquery, so a count equal to
count_limit + 1 (default 10001) actually means "at least this many" -
but only the HTML view knew that. A public count_truncated extra now
reports the flag and is implicitly included whenever count is
requested, using the same logic the HTML view already used.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GrHZSypDfMnym1tM5XJAFZ
This commit is contained in:
Claude 2026-07-04 16:09:40 +00:00
commit b958d03c0f
No known key found for this signature in database
6 changed files with 90 additions and 21 deletions

View file

@ -302,6 +302,15 @@ The available table extras are listed below.
15
``count_truncated``
True if the count hit Datasette's counting limit, meaning the real number of matching rows is at least the reported count. (May execute additional queries.)
``GET /fixtures/facetable.json?_extra=count,count_truncated``
.. code-block:: json
false
``count_sql``
SQL query string used to calculate the total count for the current table view, including active filters.