Moved comment for clarity

This commit is contained in:
Simon Willison 2020-11-29 12:27:34 -08:00
commit c745c2715a

View file

@ -247,12 +247,12 @@ class Database:
) )
if explicit_label_column: if explicit_label_column:
return explicit_label_column return explicit_label_column
# If a table has two columns, one of which is ID, then label_column is the other one
column_names = await self.execute_fn(lambda conn: table_columns(conn, table)) column_names = await self.execute_fn(lambda conn: table_columns(conn, table))
# Is there a name or title column? # Is there a name or title column?
name_or_title = [c for c in column_names if c in ("name", "title")] name_or_title = [c for c in column_names if c in ("name", "title")]
if name_or_title: if name_or_title:
return name_or_title[0] return name_or_title[0]
# If a table has two columns, one of which is ID, then label_column is the other one
if ( if (
column_names column_names
and len(column_names) == 2 and len(column_names) == 2