Skip to content

Commit

Permalink
Always pop as_format off args dict (#603)
Browse files Browse the repository at this point in the history
Closes #563. Thanks, @chris48s
  • Loading branch information
chris48s authored and simonw committed Nov 15, 2019
1 parent 6f582d7 commit f7944dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions datasette/views/base.py
Expand Up @@ -362,6 +362,8 @@ async def get_format(self, request, database, args):
_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]

Expand Down
9 changes: 9 additions & 0 deletions tests/test_api.py
Expand Up @@ -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"
Expand Down

0 comments on commit f7944dc

Please sign in to comment.