mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fix for arraycontains bug, closes #1239
This commit is contained in:
parent
42caabf7e9
commit
726f781c50
2 changed files with 10 additions and 2 deletions
|
|
@ -150,7 +150,7 @@ class Filters:
|
|||
"arraycontains",
|
||||
"array contains",
|
||||
"""rowid in (
|
||||
select {t}.rowid from {t}, json_each({t}.{c}) j
|
||||
select {t}.rowid from {t}, json_each([{t}].[{c}]) j
|
||||
where j.value = :{p}
|
||||
)""",
|
||||
'{c} contains "{v}"',
|
||||
|
|
@ -159,7 +159,7 @@ class Filters:
|
|||
"arraynotcontains",
|
||||
"array does not contain",
|
||||
"""rowid not in (
|
||||
select {t}.rowid from {t}, json_each({t}.{c}) j
|
||||
select {t}.rowid from {t}, json_each([{t}].[{c}]) j
|
||||
where j.value = :{p}
|
||||
)""",
|
||||
'{c} does not contain "{v}"',
|
||||
|
|
|
|||
|
|
@ -56,6 +56,14 @@ import pytest
|
|||
# Not in, and JSON array not in
|
||||
((("foo__notin", "1,2,3"),), ["foo not in (:p0, :p1, :p2)"], ["1", "2", "3"]),
|
||||
((("foo__notin", "[1,2,3]"),), ["foo not in (:p0, :p1, :p2)"], [1, 2, 3]),
|
||||
# JSON arraycontains
|
||||
(
|
||||
(("Availability+Info__arraycontains", "yes"),),
|
||||
[
|
||||
"rowid in (\n select table.rowid from table, json_each([table].[Availability+Info]) j\n where j.value = :p0\n )"
|
||||
],
|
||||
["yes"],
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_build_where(args, expected_where, expected_params):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue