diff --git a/c2cgeoform/views/abstract_views.py b/c2cgeoform/views/abstract_views.py index 857e54a9..3dc2a01b 100644 --- a/c2cgeoform/views/abstract_views.py +++ b/c2cgeoform/views/abstract_views.py @@ -100,8 +100,18 @@ def __init__( key: Optional[str] = None, label: Optional[str] = None, renderer: Optional[Callable[[T], JSON]] = None, - sort_column: Optional[sqlalchemy.sql.elements.ColumnElement[Any]] = None, - filter_column: Optional[sqlalchemy.sql.elements.ColumnElement[Any]] = None, + sort_column: Optional[ + Union[ + sqlalchemy.sql.elements.ColumnElement[Any], + sqlalchemy.orm.attributes.InstrumentedAttribute[Any], + ] + ] = None, + filter_column: Optional[ + Union[ + sqlalchemy.sql.elements.ColumnElement[Any], + sqlalchemy.orm.attributes.InstrumentedAttribute[Any], + ] + ] = None, visible: bool = True, ): self._attr = _getattr(model, attr) @@ -140,7 +150,12 @@ def sortable(self) -> bool: def filtrable(self) -> bool: return self._filter_column is not None and isinstance(self._filter_column.type, types.String) - def sort_column(self) -> sqlalchemy.sql.expression.ColumnElement[Any]: + def sort_column( + self, + ) -> Union[ + sqlalchemy.sql.expression.ColumnElement[Any], + sqlalchemy.orm.attributes.InstrumentedAttribute[Any], + ]: assert self._sort_column is not None return self._sort_column