Skip to content

Fix get_all_foreign_keys crash sorting implicit foreign key targets#2852

Open
santhreal wants to merge 1 commit into
simonw:mainfrom
santhreal:fix/get-all-foreign-keys-implicit-target-sort
Open

Fix get_all_foreign_keys crash sorting implicit foreign key targets#2852
santhreal wants to merge 1 commit into
simonw:mainfrom
santhreal:fix/get-all-foreign-keys-implicit-target-sort

Conversation

@santhreal

Copy link
Copy Markdown

The sort key (other_table, column, other_column) compared None against a str and raised TypeError. A foreign key targeting a table's implicit primary key has other_column = None, so any schema mixing implicit and explicit foreign keys to the same table crashed get_all_foreign_keys.

Coerce the sort-key parts to "". Adds a test with both foreign-key shapes asserting the sorted result.

A foreign key that targets a table's implicit primary key has
other_column == None. When two keys to the same table were sorted, the
(other_table, column, other_column) sort key compared None to a string
and raised TypeError. Coerce the string parts to "" so the sort key is
totally ordered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant