diff --git a/datasette/views/table.py b/datasette/views/table.py index 3e8f38f6..e6ae67de 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -915,6 +915,14 @@ class TableView(RowTableShared): links.extend(extra_links) return links + # filter_columns combine the columns we know are available + # in the table with any additional columns (such as rowid) + # which are available in the query + filter_columns = list(columns) + [ + table_column + for table_column in table_columns + if table_column not in columns + ] return { "table_actions": table_actions, "supports_search": bool(fts_table), @@ -922,7 +930,7 @@ class TableView(RowTableShared): "use_rowid": use_rowid, "filters": filters, "display_columns": display_columns, - "filter_columns": table_columns, + "filter_columns": filter_columns, "display_rows": display_rows, "facets_timed_out": facets_timed_out, "sorted_facet_results": sorted( diff --git a/tests/test_html.py b/tests/test_html.py index eb1e3d20..f24165bd 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -936,10 +936,11 @@ def test_table_html_filter_form_still_shows_nocol_columns(app_client): "pk1", "pk2", "content", - "sortable", "sortable_with_nulls", "sortable_with_nulls_2", "text", + # Moved to the end because it is no longer returned by the query: + "sortable", ]