mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Database.get_outbound_foreign_keys() refactor
Following this, the only module that ever makes calls to the low-level execute_against_connection_in_thread() method is datasette/database.py
This commit is contained in:
parent
20f98c3e20
commit
edb36629e7
3 changed files with 13 additions and 16 deletions
|
|
@ -14,8 +14,6 @@ from datasette.utils import (
|
|||
compound_keys_after_sql,
|
||||
escape_sqlite,
|
||||
filters_should_redirect,
|
||||
get_all_foreign_keys,
|
||||
get_outbound_foreign_keys,
|
||||
is_url,
|
||||
path_from_row_pks,
|
||||
path_with_added_args,
|
||||
|
|
@ -293,9 +291,8 @@ class TableView(RowTableShared):
|
|||
through_table = through_data["table"]
|
||||
other_column = through_data["column"]
|
||||
value = through_data["value"]
|
||||
outgoing_foreign_keys = await self.ds.execute_against_connection_in_thread(
|
||||
database,
|
||||
lambda conn: get_outbound_foreign_keys(conn, through_table),
|
||||
outgoing_foreign_keys = await db.get_outbound_foreign_keys(
|
||||
through_table
|
||||
)
|
||||
try:
|
||||
fk_to_us = [
|
||||
|
|
@ -843,10 +840,8 @@ class RowView(RowTableShared):
|
|||
async def foreign_key_tables(self, database, table, pk_values):
|
||||
if len(pk_values) != 1:
|
||||
return []
|
||||
|
||||
all_foreign_keys = await self.ds.execute_against_connection_in_thread(
|
||||
database, get_all_foreign_keys
|
||||
)
|
||||
db = self.ds.databases[database]
|
||||
all_foreign_keys = await db.get_all_foreign_keys()
|
||||
foreign_keys = all_foreign_keys[table]["incoming"]
|
||||
if len(foreign_keys) == 0:
|
||||
return []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue