Compound primary key _next= now plays well with extra filters

Closes #190
This commit is contained in:
Simon Willison 2018-03-29 23:26:22 -07:00
commit 7365c3f51c
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
5 changed files with 50 additions and 19 deletions

View file

@ -227,16 +227,16 @@ def test_temporary_docker_directory_uses_copy_if_hard_link_fails(mock_link):
def test_compound_keys_after_sql():
assert '([a] > :p0)' == utils.compound_keys_after_sql(['a'])
assert '(([a] > :p0))' == utils.compound_keys_after_sql(['a'])
assert '''
([a] > :p0)
(([a] > :p0)
or
([a] = :p0 and [b] > :p1)
([a] = :p0 and [b] > :p1))
'''.strip() == utils.compound_keys_after_sql(['a', 'b'])
assert '''
([a] > :p0)
(([a] > :p0)
or
([a] = :p0 and [b] > :p1)
or
([a] = :p0 and [b] = :p1 and [c] > :p2)
([a] = :p0 and [b] = :p1 and [c] > :p2))
'''.strip() == utils.compound_keys_after_sql(['a', 'b', 'c'])