Skip to content

Commit

Permalink
fix prefetch when a ForeignKey has db_column_name set
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Oct 18, 2024
1 parent e2fa8f8 commit 2de72c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion piccolo/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ def get_column_by_name(self, name: str) -> Column:
"""
components = name.split(".")
column_name = components[0]
column = [i for i in self.columns if i._meta.name == column_name]
column = [
i
for i in self.columns
if column_name in (i._meta.name, i._meta.db_column_name)
]
if len(column) != 1:
raise ValueError(f"No matching column found with name == {name}")
column_object = column[0]
Expand Down

0 comments on commit 2de72c7

Please sign in to comment.