Skip to content
Permalink
Browse files

New ?column__date=yyyy-mm-dd filter

  • Loading branch information...
simonw committed Apr 15, 2019
1 parent 1c6649b commit 583b22aa28e26c318de0189312350ab2688c90b1
Showing with 12 additions and 0 deletions.
  1. +1 −0 datasette/filters.py
  2. +3 −0 docs/json_api.rst
  3. +8 −0 tests/test_filters.py
@@ -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),
@@ -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.

@@ -60,6 +60,14 @@
['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)
(
{

0 comments on commit 583b22a

Please sign in to comment.
You can’t perform that action at this time.