diff --git a/datasette/utils.py b/datasette/utils.py index 5ef21488..fe7c58e1 100644 --- a/datasette/utils.py +++ b/datasette/utils.py @@ -332,6 +332,7 @@ class Filter: class Filters: _filters = [ Filter('exact', '=', '"{c}" = :{p}', lambda c, v: '{c} = {v}' if v.isdigit() else '{c} = "{v}"'), + Filter('not', '!=', '"{c}" != :{p}', lambda c, v: '{c} != {v}' if v.isdigit() else '{c} != "{v}"'), Filter('contains', 'contains', '"{c}" like :{p}', '{c} contains "{v}"', format='%{}%'), Filter('endswith', 'ends with', '"{c}" like :{p}', '{c} ends with "{v}"', format='%{}'), Filter('startswith', 'starts with', '"{c}" like :{p}', '{c} starts with "{v}"', format='{}%'), diff --git a/tests/test_app.py b/tests/test_app.py index 41a34c64..881f5b06 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -254,6 +254,10 @@ def test_paginate_tables_and_views(app_client, path, expected_rows, expected_pag ('/test_tables/simple_primary_key.json?content__exact=', [ ['3', ''], ]), + ('/test_tables/simple_primary_key.json?content__not=world', [ + ['1', 'hello'], + ['3', ''], + ]), ]) def test_table_filter_queries(app_client, path, expected_rows): response = app_client.get(path, gather_request=False)