mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Include rowid in filter select, closes #636
This commit is contained in:
parent
a9909c29cc
commit
440a70428c
2 changed files with 25 additions and 5 deletions
|
|
@ -587,10 +587,6 @@ class TableView(RowTableShared):
|
|||
columns = [r[0] for r in results.description]
|
||||
rows = list(results.rows)
|
||||
|
||||
filter_columns = columns[:]
|
||||
if use_rowid and filter_columns[0] == "rowid":
|
||||
filter_columns = filter_columns[1:]
|
||||
|
||||
# Expand labeled columns if requested
|
||||
expanded_columns = []
|
||||
expandable_columns = await self.expandable_columns(database, table)
|
||||
|
|
@ -720,7 +716,7 @@ class TableView(RowTableShared):
|
|||
"use_rowid": use_rowid,
|
||||
"filters": filters,
|
||||
"display_columns": display_columns,
|
||||
"filter_columns": filter_columns,
|
||||
"filter_columns": columns,
|
||||
"display_rows": display_rows,
|
||||
"facets_timed_out": facets_timed_out,
|
||||
"sorted_facet_results": sorted(
|
||||
|
|
|
|||
|
|
@ -679,6 +679,30 @@ def test_table_html_foreign_key_custom_label_column(app_client):
|
|||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"path,expected_column_options",
|
||||
[
|
||||
("/fixtures/infinity", ["- column -", "rowid", "value"]),
|
||||
(
|
||||
"/fixtures/primary_key_multiple_columns",
|
||||
["- column -", "id", "content", "content2"],
|
||||
),
|
||||
("/fixtures/compound_primary_key", ["- column -", "pk1", "pk2", "content"]),
|
||||
],
|
||||
)
|
||||
def test_table_html_filter_form_column_options(
|
||||
path, expected_column_options, app_client
|
||||
):
|
||||
response = app_client.get(path)
|
||||
assert response.status == 200
|
||||
form = Soup(response.body, "html.parser").find("form")
|
||||
column_options = [
|
||||
o.attrs.get("value") or o.string
|
||||
for o in form.select("select[name=_filter_column] option")
|
||||
]
|
||||
assert expected_column_options == column_options
|
||||
|
||||
|
||||
def test_row_html_compound_primary_key(app_client):
|
||||
response = app_client.get("/fixtures/compound_primary_key/a,b")
|
||||
assert response.status == 200
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue