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

@ -26,6 +26,13 @@ def app_client():
yield ds.app().test_client
def generate_compound_rows(num):
for a, b, c in itertools.islice(
itertools.product(string.ascii_lowercase, repeat=3), num
):
yield a, b, c, '{}-{}-{}'.format(a, b, c)
METADATA = {
'title': 'Datasette Title',
'description': 'Datasette Description',
@ -124,9 +131,7 @@ CREATE VIEW simple_view AS
'INSERT INTO no_primary_key VALUES ({i}, "a{i}", "b{i}", "c{i}");'.format(i=i + 1)
for i in range(201)
]) + '\n'.join([
'INSERT INTO compound_three_primary_keys VALUES ("{a}", "{b}", "{c}", "{a}-{b}-{c}");'.format(
a=a, b=b, c=c
) for a, b, c in itertools.islice(
itertools.product(string.ascii_lowercase, repeat=3), 301
)
'INSERT INTO compound_three_primary_keys VALUES ("{a}", "{b}", "{c}", "{content}");'.format(
a=a, b=b, c=c, content=content
) for a, b, c, content in generate_compound_rows(1001)
])