diff --git a/piccolo/table.py b/piccolo/table.py index bae9b8a47..1543912d5 100644 --- a/piccolo/table.py +++ b/piccolo/table.py @@ -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]