mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Started implementing ?name__contains=X filters
So far we support __contains=, __startswith=, __endswith= and __exact= Refs #23
This commit is contained in:
parent
4c7379a898
commit
1ae8ea0f03
2 changed files with 59 additions and 1 deletions
|
|
@ -64,3 +64,22 @@ def test_custom_json_encoder(obj, expected):
|
|||
sort_keys=True
|
||||
)
|
||||
assert expected == actual
|
||||
|
||||
|
||||
@pytest.mark.parametrize('args,expected_where,expected_params', [
|
||||
({
|
||||
'name_english__contains': ['foo'],
|
||||
}, '"name_english" like ?', ['%foo%']),
|
||||
({
|
||||
'foo': ['bar'],
|
||||
'bar__contains': ['baz'],
|
||||
}, '"bar" like ? and "foo" = ?', ['%baz%', 'bar']),
|
||||
({
|
||||
'foo__startswith': ['bar'],
|
||||
'bar__endswith': ['baz'],
|
||||
}, '"bar" like ? and "foo" like ?', ['%baz', 'bar%']),
|
||||
])
|
||||
def test_build_where(args, expected_where, expected_params):
|
||||
actual_where, actual_params = app.build_where_clause(args)
|
||||
assert expected_where == actual_where
|
||||
assert expected_params == actual_params
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue