Skip to content

Commit 5a70588

Browse files
committed
fix(sql): accept QueryableAttribute and ColumnElement in col() helper
1 parent 8f44815 commit 5a70588

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

sqlmodel/sql/expression.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
TypeCoerce,
1919
WithinGroup,
2020
)
21-
from sqlalchemy.orm import InstrumentedAttribute, Mapped
21+
from sqlalchemy.orm import InstrumentedAttribute, Mapped, QueryableAttribute
2222
from sqlalchemy.sql._typing import (
2323
_ColumnExpressionArgument,
2424
_ColumnExpressionOrLiteralArgument,
@@ -197,6 +197,9 @@ def within_group(
197197

198198

199199
def col(column_expression: _T) -> Mapped[_T]:
200-
if not isinstance(column_expression, (ColumnClause, Column, InstrumentedAttribute)):
200+
if not isinstance(
201+
column_expression,
202+
(ColumnClause, Column, InstrumentedAttribute, QueryableAttribute, ColumnElement),
203+
):
201204
raise RuntimeError(f"Not a SQLAlchemy column: {column_expression}")
202205
return column_expression # type: ignore

0 commit comments

Comments
 (0)