Removed db.get_outbound_foreign_keys method

It duplicated the functionality of db.foreign_keys_for_table.
This commit is contained in:
Simon Willison 2020-05-30 11:39:46 -07:00
commit 124acf34a6
3 changed files with 2 additions and 9 deletions

View file

@ -319,11 +319,6 @@ class Database:
async def get_all_foreign_keys(self):
return await self.execute_fn(get_all_foreign_keys)
async def get_outbound_foreign_keys(self, table):
return await self.execute_fn(
lambda conn: get_outbound_foreign_keys(conn, table)
)
async def get_table_definition(self, table, type_="table"):
table_definition_rows = list(
await self.execute(

View file

@ -428,7 +428,7 @@ def get_outbound_foreign_keys(conn, table):
if info is not None:
id, seq, table_name, from_, to_, on_update, on_delete, match = info
fks.append(
{"other_table": table_name, "column": from_, "other_column": to_}
{"column": from_, "other_table": table_name, "other_column": to_}
)
return fks

View file

@ -336,9 +336,7 @@ class TableView(RowTableShared):
through_table = through_data["table"]
other_column = through_data["column"]
value = through_data["value"]
outgoing_foreign_keys = await db.get_outbound_foreign_keys(
through_table
)
outgoing_foreign_keys = await db.foreign_keys_for_table(through_table)
try:
fk_to_us = [
fk for fk in outgoing_foreign_keys if fk["other_table"] == table