New ?column__date=yyyy-mm-dd filter

pull/432/head
Simon Willison 2019-04-15 15:54:54 -07:00
rodzic 1c6649b19b
commit 583b22aa28
3 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -100,6 +100,7 @@ class Filters:
where j.value = :{p}
)""", '{c} contains "{v}"')
] if detect_json1() else []) + [
TemplatedFilter('date', 'date', 'date({c}) = :{p}', '"{c}" is on date {v}'),
TemplatedFilter('isnull', 'is null', '"{c}" is null', '{c} is null', no_argument=True),
TemplatedFilter('notnull', 'is not null', '"{c}" is not null', '{c} is not null', no_argument=True),
TemplatedFilter('isblank', 'is blank', '("{c}" is null or "{c}" = "")', '{c} is blank', no_argument=True),

Wyświetl plik

@ -233,6 +233,9 @@ You can filter the data returned by the table based on column values using a que
This is only available if the ``json1`` SQLite extension is enabled.
``?column__date=value``
Column is a datestamp occurring on the specified YYYY-MM-DD date, e.g. ``2018-01-02``.
``?column__isnull=1``
Matches rows where the column is null.

Wyświetl plik

@ -60,6 +60,14 @@ import pytest
['foo in (:p0, :p1, :p2)'],
["1", "2", "3"]
),
# date
(
{
"foo__date": "1988-01-01",
},
["date(foo) = :p0"],
["1988-01-01"]
),
# JSON array variants of __in (useful for unexpected characters)
(
{