Fixed weird edge-case with foreign key detection

It turns out it is possible for a SQLite table to define a foreign key
relationship to a table that does not actually exist

We should still be able to handle these databases.
pull/118/head
Simon Willison 2017-11-17 08:18:26 -08:00
rodzic 45e502aace
commit 0b702f3679
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -219,6 +219,10 @@ def get_all_foreign_keys(conn):
for info in infos:
if info is not None:
id, seq, table_name, from_, to_, on_update, on_delete, match = info
if table_name not in table_to_foreign_keys:
# Weird edge case where something refers to a table that does
# not actually exist
continue
table_to_foreign_keys[table_name]['incoming'].append({
'other_table': table,
'column': to_,