Skip to content

Commit

Permalink
Persist _where= in hidden fields, closes #604
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Oct 30, 2019
1 parent 5dd4d2b commit e2c3905
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions datasette/views/table.py
Expand Up @@ -721,6 +721,9 @@ async def extra_template():
for arg in ("_fts_table", "_fts_pk"):
if arg in special_args:
form_hidden_args.append((arg, special_args[arg]))
if request.args["_where"]:
for where_text in request.args["_where"]:
form_hidden_args.append(("_where", where_text))
return {
"supports_search": bool(fts_table),
"search": search or "",
Expand Down
6 changes: 6 additions & 0 deletions tests/test_html.py
Expand Up @@ -955,6 +955,12 @@ def test_extra_where_clauses(app_client):
"/fixtures/facetable?_where=city_id%3D1",
"/fixtures/facetable?_where=neighborhood%3D%27Dogpatch%27",
] == hrefs
# These should also be persisted as hidden fields
inputs = soup.find("form").findAll("input")
hiddens = [i for i in inputs if i["type"] == "hidden"]
assert [("_where", "neighborhood='Dogpatch'"), ("_where", "city_id=1")] == [
(hidden["name"], hidden["value"]) for hidden in hiddens
]


def test_binary_data_display(app_client):
Expand Down

0 comments on commit e2c3905

Please sign in to comment.