mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Fix TypeError when sorting mixed compound/single foreign keys
sorted() on a foreign_keys list containing both compound (column=None) and single-column ForeignKeys raised TypeError because dataclass ordering compared None against str. column/other_column are now excluded from comparison - ordering and equality use the always populated columns/other_columns lists instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
f10459cffb
commit
d5bf51df35
2 changed files with 32 additions and 2 deletions
|
|
@ -182,9 +182,11 @@ class ForeignKey:
|
|||
"""
|
||||
|
||||
table: str
|
||||
column: Optional[str]
|
||||
# column/other_column are None for compound keys, which would break
|
||||
# ordering against str values - comparison uses columns/other_columns
|
||||
column: Optional[str] = field(compare=False)
|
||||
other_table: str
|
||||
other_column: Optional[str]
|
||||
other_column: Optional[str] = field(compare=False)
|
||||
columns: List[str] = field(default_factory=list)
|
||||
other_columns: List[str] = field(default_factory=list)
|
||||
is_compound: bool = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue