Added glob and like lookups - refs #23

pull/383/head
Simon Willison 2017-10-24 18:53:01 -07:00
rodzic 630b40038e
commit 1c5977961f
2 zmienionych plików z 10 dodań i 0 usunięć

2
app.py
Wyświetl plik

@ -329,6 +329,8 @@ def build_where_clause(args):
'gte': '"{}" >= ?',
'lt': '"{}" < ?',
'lte': '"{}" <= ?',
'glob': '"{}" glob ?',
'like': '"{}" like ?',
}[lookup]
value = values[0]
value_convert = {

Wyświetl plik

@ -100,6 +100,14 @@ def test_custom_json_encoder(obj, expected):
'"bar" > ? and "bax" <= ? and "baz" >= ? and "foo" < ?',
['2', '4', '3', '1']
),
(
{
'foo__like': ['2%2'],
'zax__glob': ['3*'],
},
'"foo" like ? and "zax" glob ?',
['2%2', '3*']
),
])
def test_build_where(args, expected_where, expected_params):
actual_where, actual_params = app.build_where_clause(args)