Facets no longer consider null values

pull/261/head
Simon Willison 2018-05-14 19:19:43 -03:00
rodzic ce84d76fff
commit b163b41ddf
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 17E2DEA2588B7F52
1 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -497,10 +497,12 @@ class TableView(RowTableShared):
for column in facets: for column in facets:
facet_sql = """ facet_sql = """
select {col} as value, count(*) as count select {col} as value, count(*) as count
{from_sql} {from_sql} {and_or_where} {col} is not null
group by {col} order by count desc limit 20 group by {col} order by count desc limit 20
""".format( """.format(
col=escape_sqlite(column), from_sql=from_sql col=escape_sqlite(column),
from_sql=from_sql,
and_or_where='and' if where_clauses else 'where',
) )
try: try:
facet_rows = await self.execute( facet_rows = await self.execute(
@ -580,11 +582,17 @@ class TableView(RowTableShared):
for facet_column in columns: for facet_column in columns:
if facet_column in facets: if facet_column in facets:
continue continue
suggested_facet_sql = 'select distinct {column} {from_sql} limit {limit}'.format( suggested_facet_sql = '''
select distinct {column} {from_sql}
{and_or_where} {column} is not null
limit {limit}
'''.format(
column=escape_sqlite(facet_column), column=escape_sqlite(facet_column),
from_sql=from_sql, from_sql=from_sql,
and_or_where='and' if where_clauses else 'where',
limit=FACET_LIMIT+1 limit=FACET_LIMIT+1
) )
print(suggested_facet_sql)
distinct_values = None distinct_values = None
try: try:
distinct_values = await self.execute( distinct_values = await self.execute(