Always pop as_format off args dict (#603)

Closes #563. Thanks, @chris48s
pull/609/head
chris48s 2019-10-21 03:03:08 +01:00 zatwierdzone przez Simon Willison
rodzic 8050f9e1ec
commit f4c0830529
2 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -362,6 +362,8 @@ class DataView(BaseView):
_format = request.args.get("_format", None)
if not _format:
_format = (args.pop("as_format", None) or "").lstrip(".")
else:
args.pop("as_format", None)
if "table_and_format" in args:
db = self.ds.databases[database]

Wyświetl plik

@ -1107,6 +1107,15 @@ def test_row(app_client):
assert [{"id": "1", "content": "hello"}] == response.json["rows"]
def test_row_format_in_querystring(app_client):
# regression test for https://github.com/simonw/datasette/issues/563
response = app_client.get(
"/fixtures/simple_primary_key/1?_format=json&_shape=objects"
)
assert response.status == 200
assert [{"id": "1", "content": "hello"}] == response.json["rows"]
def test_row_strange_table_name(app_client):
response = app_client.get(
"/fixtures/table%2Fwith%2Fslashes.csv/3.json?_shape=objects"