diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 704931a6..d45a6f31 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,7 @@ jobs: - name: Install dependencies run: | pip install -e '.[test]' + pip freeze - name: Run tests run: | pytest -n auto -m "not serial" diff --git a/datasette/cli.py b/datasette/cli.py index 9d1b5ee5..a8da0741 100644 --- a/datasette/cli.py +++ b/datasette/cli.py @@ -549,6 +549,11 @@ def serve( ) ) + # De-duplicate files so 'datasette db.db db.db' only attaches one /db + files_seen = set() + deduped_files = [f for f in files if f not in files_seen and not files_seen.add(f)] + files = deduped_files + try: ds = Datasette(files, **kwargs) except SpatialiteNotFound: diff --git a/datasette/version.py b/datasette/version.py index a4e340b3..91224615 100644 --- a/datasette/version.py +++ b/datasette/version.py @@ -1,2 +1,2 @@ -__version__ = "0.60" +__version__ = "0.60.2" __version_info__ = tuple(__version__.split(".")) diff --git a/docs/changelog.rst b/docs/changelog.rst index d7e2af39..c58c8444 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,20 @@ Changelog ========= +.. _v0_60.2: + +0.60.2 (2022-02-07) +------------------- + +- Fixed a bug where Datasette would open the same file twice with two different database names if you ran ``datasette file.db file.db``. (:issue:`1632`) + +.. _v0_60.1: + +0.60.1 (2022-01-20) +------------------- + +- Fixed a bug where installation on Python 3.6 stopped working due to a change to an underlying dependency. This release can now be installed on Python 3.6, but is the last release of Datasette that will support anything less than Python 3.7. (:issue:`1609`) + .. _v0_60: 0.60 (2022-01-13) diff --git a/setup.py b/setup.py index e9ef082a..092ae172 100644 --- a/setup.py +++ b/setup.py @@ -58,6 +58,23 @@ setup( "mergedeep>=1.1.1,<1.4.0", "itsdangerous>=1.1,<3.0", "python-baseconv==1.2.2", + # The following are known to work with 3.6 + 'asgiref<=3.4.1;python_version<="3.6"', + 'click<=8.0.3;python_version<="3.6"', + 'click-default-group<=1.2.2;python_version<="3.6"', + 'Jinja2<=3.0.3;python_version<="3.6"', + 'hupper<=1.10.3;python_version<="3.6"', + 'httpx<=0.21.3;python_version<="3.6"', + 'pint<=0.17;python_version<="3.6"', + 'pluggy<=1.0.0;python_version<="3.6"', + 'uvicorn<=0.16.0;python_version<="3.6"', + 'aiofiles<=0.8.0;python_version<="3.6"', + 'janus<=0.7.0;python_version<="3.6"', + 'asgi-csrf<=0.9;python_version<="3.6"', + 'PyYAML<=6.0;python_version<="3.6"', + 'mergedeep<=1.3.4;python_version<="3.6"', + 'itsdangerous<=2.0.1;python_version<="3.6"', + 'python-baseconv<=1.2.2;python_version<="3.6"', ], entry_points=""" [console_scripts] @@ -67,14 +84,14 @@ setup( extras_require={ "docs": ["sphinx_rtd_theme", "sphinx-autobuild", "codespell"], "test": [ - "pytest>=5.2.2,<6.3.0", - "pytest-xdist>=2.2.1,<2.6", - "pytest-asyncio>=0.10,<0.17", - "beautifulsoup4>=4.8.1,<4.11.0", + "pytest==6.2.5", + "pytest-xdist==2.5.0", + "pytest-asyncio==0.16.0", + "beautifulsoup4==4.10.0", "black==21.12b0", - "pytest-timeout>=1.4.2,<2.1", - "trustme>=0.7,<0.10", - "cogapp>=3.3.0", + "pytest-timeout==2.0.2", + "trustme==0.9.0", + "cogapp==3.3.0", ], "rich": ["rich"], }, diff --git a/tests/test_cli.py b/tests/test_cli.py index 763fe2e7..9da99d87 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -259,6 +259,7 @@ def test_serve_create(ensure_eventloop, tmpdir): def test_serve_duplicate_database_names(ensure_eventloop, tmpdir): + "'datasette db.db nested/db.db' should attach two databases, /db and /db_2" runner = CliRunner() db_1_path = str(tmpdir / "db.db") nested = tmpdir / "nested" @@ -272,6 +273,17 @@ def test_serve_duplicate_database_names(ensure_eventloop, tmpdir): assert {db["name"] for db in databases} == {"db", "db_2"} +def test_serve_deduplicate_same_database_path(ensure_eventloop, tmpdir): + "'datasette db.db db.db' should only attach one database, /db" + runner = CliRunner() + db_path = str(tmpdir / "db.db") + sqlite3.connect(db_path).execute("vacuum") + result = runner.invoke(cli, [db_path, db_path, "--get", "/-/databases.json"]) + assert result.exit_code == 0, result.output + databases = json.loads(result.output) + assert {db["name"] for db in databases} == {"db"} + + @pytest.mark.parametrize( "filename", ["test-database (1).sqlite", "database (1).sqlite"] )