Spotted this bug using mypy while working on #311 / #312!
% mypy sqlite_utils
sqlite_utils/db.py:725: error: Item "View" of "Union[Table, View]" has no attribute "foreign_keys"
Found 1 error in 1 file (checked 5 source files)
Refers to this code:
|
# We will silently skip foreign keys that exist already |
|
if not any( |
|
fk |
|
for fk in self[table].foreign_keys |
|
if fk.column == column |
|
and fk.other_table == other_table |
|
and fk.other_column == other_column |
|
): |
|
foreign_keys_to_create.append( |
|
(table, column, other_table, other_column) |
|
) |
It's a bug! We run some checks earlier but none of them ensure that it's a view:
|
if not self[table].exists(): |
|
raise AlterError("No such table: {}".format(table)) |
|
if column not in self[table].columns_dict: |
|
raise AlterError("No such column: {} in {}".format(column, table)) |
|
if not self[other_table].exists(): |
|
raise AlterError("No such other_table: {}".format(other_table)) |
|
if ( |
|
other_column != "rowid" |
|
and other_column not in self[other_table].columns_dict |
|
): |
|
raise AlterError( |
|
"No such other_column: {} in {}".format(other_column, other_table) |
|
) |
Spotted this bug using
mypywhile working on #311 / #312!Refers to this code:
sqlite-utils/sqlite_utils/db.py
Lines 710 to 720 in c11ff89
It's a bug! We run some checks earlier but none of them ensure that it's a view:
sqlite-utils/sqlite_utils/db.py
Lines 697 to 709 in c11ff89