Fix for FTS virtual table counting error

column-sort
Simon Willison 2018-03-20 18:26:04 -07:00
rodzic 56623e48da
commit 012fc7c5cd
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 17E2DEA2588B7F52
1 zmienionych plików z 8 dodań i 3 usunięć

Wyświetl plik

@ -929,9 +929,14 @@ class Datasette:
]
views = [v[0] for v in conn.execute('select name from sqlite_master where type = "view"')]
for table in table_names:
count = conn.execute(
'select count(*) from {}'.format(escape_sqlite_table_name(table))
).fetchone()[0]
try:
count = conn.execute(
'select count(*) from {}'.format(escape_sqlite_table_name(table))
).fetchone()[0]
except sqlite3.OperationalError:
# This can happen when running against a FTS virtual tables
# e.g. "select count(*) from some_fts;"
count = 0
label_column = None
# If table has two columns, one of which is ID, then label_column is the other one
column_names = [r[1] for r in conn.execute(