Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

?_nocol= removes that column from the filter interface #1503

Closed
simonw opened this issue Nov 10, 2021 · 1 comment
Closed

?_nocol= removes that column from the filter interface #1503

simonw opened this issue Nov 10, 2021 · 1 comment
Labels

Comments

@simonw
Copy link
Owner

simonw commented Nov 10, 2021

e.g. on https://latest.datasette.io/fixtures/sortable?_nocol=sortable

fixtures__sortable__201_rows

This causes weird behaviour when you e.g. facet by a hidden column, since selecting facets and then re-submitting the form will clear the selected filter.

nocol-bug

@simonw simonw added the bug label Nov 10, 2021
@simonw simonw closed this as completed in c9e3cfe Nov 14, 2021
@simonw
Copy link
Owner Author

simonw commented Nov 14, 2021

Error:

    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
E       AssertionError: assert ['- column -'...wid', 'value'] == ['- column -', 'value']
E         At index 1 diff: 'rowid' != 'value'
E         Left contains one more item: 'value'
E         Use -v to get the full diff

This is because rowid isn't a table column but IS returned by the query used on that page.

My solution: start with the query columns, but then add any table columns that were not already returned by the query to the end of the filter_columns list.

simonw added a commit that referenced this issue Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant