?column_notcontains= table filter, closes #2287

pull/2288/head
Simon Willison 2024-02-27 16:07:37 -08:00
rodzic c863443ea1
commit f99c2f5f8c
3 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -281,6 +281,13 @@ class Filters:
'{c} contains "{v}"',
format="%{}%",
),
TemplatedFilter(
"notcontains",
"does not contain",
'"{c}" not like :{p}',
'{c} does not contain "{v}"',
format="%{}%",
),
TemplatedFilter(
"endswith",
"ends with",

Wyświetl plik

@ -237,6 +237,9 @@ You can filter the data returned by the table based on column values using a que
``?column__contains=value``
Rows where the string column contains the specified value (``column like "%value%"`` in SQL).
``?column__notcontains=value``
Rows where the string column does not contain the specified value (``column not like "%value%"`` in SQL).
``?column__endswith=value``
Rows where the string column ends with the specified value (``column like "%value"`` in SQL).

Wyświetl plik

@ -7,6 +7,11 @@ import pytest
"args,expected_where,expected_params",
[
((("name_english__contains", "foo"),), ['"name_english" like :p0'], ["%foo%"]),
(
(("name_english__notcontains", "foo"),),
['"name_english" not like :p0'],
["%foo%"],
),
(
(("foo", "bar"), ("bar__contains", "baz")),
['"bar" like :p0', '"foo" = :p1'],