Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions sqlmodel/sql/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
TypeCoerce,
WithinGroup,
)
from sqlalchemy.orm import InstrumentedAttribute, Mapped
from sqlalchemy.orm import InstrumentedAttribute, Mapped, QueryableAttribute
from sqlalchemy.sql._typing import (
_ColumnExpressionArgument,
_ColumnExpressionOrLiteralArgument,
Expand Down Expand Up @@ -197,6 +197,15 @@ def within_group(


def col(column_expression: _T) -> Mapped[_T]:
if not isinstance(column_expression, (ColumnClause, Column, InstrumentedAttribute)):
if not isinstance(
column_expression,
(
ColumnClause,
Column,
InstrumentedAttribute,
QueryableAttribute,
ColumnElement,
),
):
raise RuntimeError(f"Not a SQLAlchemy column: {column_expression}")
return column_expression # type: ignore
Loading