mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Compare commits
5 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe9d4a5ffe | ||
|
|
8cc5a8dc35 | ||
|
|
767e29c404 | ||
|
|
1186ca1eac | ||
|
|
8790acfbf1 |
4 changed files with 47 additions and 8 deletions
|
|
@ -193,14 +193,14 @@ class DataView(BaseView):
|
|||
async def resolve_db_name(self, request, db_name, **kwargs):
|
||||
hash = None
|
||||
name = None
|
||||
if "-" in db_name:
|
||||
# Might be name-and-hash, or might just be
|
||||
# a name with a hyphen in it
|
||||
name, hash = db_name.rsplit("-", 1)
|
||||
if name not in self.ds.databases:
|
||||
# Try the whole name
|
||||
name = db_name
|
||||
hash = None
|
||||
if db_name not in self.ds.databases and "-" in db_name:
|
||||
# No matching DB found, maybe it's a name-hash?
|
||||
name_bit, hash_bit = db_name.rsplit("-", 1)
|
||||
if name_bit not in self.ds.databases:
|
||||
raise NotFound("Database not found: {}".format(name))
|
||||
else:
|
||||
name = name_bit
|
||||
hash = hash_bit
|
||||
else:
|
||||
name = db_name
|
||||
# Verify the hash
|
||||
|
|
|
|||
|
|
@ -4,6 +4,20 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
.. _v0_30:
|
||||
|
||||
0.30 (2019-10-18)
|
||||
-----------------
|
||||
|
||||
- Added ``/-/threads`` debugging page
|
||||
- Allow ``EXPLAIN WITH...`` (`#583 <https://github.com/simonw/datasette/issues/583>`__)
|
||||
- Button to format SQL - thanks, Tobias Kunze (`#136 <https://github.com/simonw/datasette/issues/136>`__)
|
||||
- Sort databases on homepage by argument order - thanks, Tobias Kunze (`#585 <https://github.com/simonw/datasette/issues/585>`__)
|
||||
- Display metadata footer on custom SQL queries - thanks, Tobias Kunze (`#589 <https://github.com/simonw/datasette/pull/589>`__)
|
||||
- Use ``--platform=managed`` for ``publish cloudrun`` (`#587 <https://github.com/simonw/datasette/issues/587>`__)
|
||||
- Fixed bug returning non-ASCII characters in CSV (`#584 <https://github.com/simonw/datasette/issues/584>`__)
|
||||
- Fix for ``/foo`` v.s. ``/foo-bar`` bug (`#601 <https://github.com/simonw/datasette/issues/601>`__)
|
||||
|
||||
.. _v0_29_3:
|
||||
|
||||
0.29.3 (2019-09-02)
|
||||
|
|
|
|||
|
|
@ -178,6 +178,13 @@ def app_client_two_attached_databases():
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def app_client_conflicting_database_names():
|
||||
yield from make_app_client(
|
||||
extra_databases={"foo.db": EXTRA_DATABASE_SQL, "foo-bar.db": EXTRA_DATABASE_SQL}
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def app_client_two_attached_databases_one_immutable():
|
||||
yield from make_app_client(
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from .fixtures import ( # noqa
|
|||
app_client_larger_cache_size,
|
||||
app_client_returned_rows_matches_page_size,
|
||||
app_client_two_attached_databases_one_immutable,
|
||||
app_client_conflicting_database_names,
|
||||
app_client_with_cors,
|
||||
app_client_with_dot,
|
||||
generate_compound_rows,
|
||||
|
|
@ -1652,3 +1653,20 @@ def test_cors(app_client_with_cors, path, status_code):
|
|||
response = app_client_with_cors.get(path)
|
||||
assert response.status == status_code
|
||||
assert "*" == response.headers["Access-Control-Allow-Origin"]
|
||||
|
||||
|
||||
def test_common_prefix_database_names(app_client_conflicting_database_names):
|
||||
# https://github.com/simonw/datasette/issues/597
|
||||
assert ["fixtures", "foo", "foo-bar"] == [
|
||||
d["name"]
|
||||
for d in json.loads(
|
||||
app_client_conflicting_database_names.get("/-/databases.json").body.decode(
|
||||
"utf8"
|
||||
)
|
||||
)
|
||||
]
|
||||
for db_name, path in (("foo", "/foo.json"), ("foo-bar", "/foo-bar.json")):
|
||||
data = json.loads(
|
||||
app_client_conflicting_database_names.get(path).body.decode("utf8")
|
||||
)
|
||||
assert db_name == data["database"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue