Simplify drop-foreign-key, and drop_foreign_keys, closes #177

This commit is contained in:
Simon Willison 2020-09-24 09:19:07 -07:00
commit 5a63b9e88c
6 changed files with 6 additions and 18 deletions

View file

@ -924,7 +924,7 @@ def rows(ctx, path, dbtable, nl, arrays, csv, no_headers, table, fmt, json_cols)
)
@click.option(
"--drop-foreign-key",
type=(str, str, str),
type=str,
multiple=True,
help="Drop this foreign key constraint",
)

View file

@ -835,9 +835,7 @@ class Table(Queryable):
# foreign_keys
create_table_foreign_keys = []
for table, column, other_table, other_column in self.foreign_keys:
if (drop_foreign_keys is None) or (
(column, other_table, other_column) not in drop_foreign_keys
):
if (drop_foreign_keys is None) or (column not in drop_foreign_keys):
create_table_foreign_keys.append(
(rename.get(column) or column, other_table, other_column)
)