From 03e44cfbd38dd340fe5fadbc253341655f0d8b92 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Thu, 18 Apr 2024 09:13:00 +0100 Subject: [PATCH] bugfix: correctly detect json1 in versions.json Fixes simonw/datasette#2326 --- datasette/app.py | 4 ++-- tests/test_api.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/datasette/app.py b/datasette/app.py index 23d21600c6..8f3a204e5f 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -68,6 +68,7 @@ async_call_with_supported_arguments, await_me_maybe, call_with_supported_arguments, + detect_json1, display_actor, escape_css_string, escape_sqlite, @@ -1102,9 +1103,8 @@ def _versions(self): conn = sqlite3.connect(":memory:") self._prepare_connection(conn, "_memory") sqlite_version = conn.execute("select sqlite_version()").fetchone()[0] - sqlite_extensions = {} + sqlite_extensions = {"json1": detect_json1(conn)} for extension, testsql, hasversion in ( - ("json1", "SELECT json('{}')", False), ("spatialite", "SELECT spatialite_version()", True), ): try: diff --git a/tests/test_api.py b/tests/test_api.py index 4ad55d7253..2f95658488 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -818,6 +818,10 @@ async def test_versions_json(ds_client): assert "version" in data["sqlite"] assert "fts_versions" in data["sqlite"] assert "compile_options" in data["sqlite"] + # By default, the json1 extension is enabled in the SQLite + # provided by the `ubuntu-latest` github actions runner, and + # all versions of SQLite from 3.38.0 onwards + assert data["sqlite"]["extensions"]["json1"] @pytest.mark.asyncio