mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-15 22:37:32 -04:00
re-implement PrivateColumn to make sqlalchemy happy
This commit is contained in:
@@ -14,12 +14,16 @@ from ._model_utils.datetime import NaiveDateTime, get_utc_now
|
|||||||
NORMALIZE_PUNCTUATION = string.punctuation.replace("'", "").replace('"', "")
|
NORMALIZE_PUNCTUATION = string.punctuation.replace("'", "").replace('"', "")
|
||||||
_NORMALIZE_PUNCTUATION_TABLE = str.maketrans(NORMALIZE_PUNCTUATION, " " * len(NORMALIZE_PUNCTUATION))
|
_NORMALIZE_PUNCTUATION_TABLE = str.maketrans(NORMALIZE_PUNCTUATION, " " * len(NORMALIZE_PUNCTUATION))
|
||||||
|
|
||||||
type PrivateColumn[T] = Mapped[Annotated[T, mapped_column(info={"private": True})]]
|
|
||||||
|
class PrivateColumn[T]:
|
||||||
"""
|
"""
|
||||||
A `Mapped` attribute with metadata `private=True`.
|
Drop-in replacement for `Mapped[]` that marks a column as private.
|
||||||
Signals to the query filter API not to allow using this field in query operations.
|
Private columns cannot be used in query filter expressions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __class_getitem__(cls, item: type) -> type:
|
||||||
|
return Mapped[Annotated[item, mapped_column(info={"private": True})]]
|
||||||
|
|
||||||
|
|
||||||
class SqlAlchemyBase(DeclarativeBase):
|
class SqlAlchemyBase(DeclarativeBase):
|
||||||
__filter_restricted__: ClassVar[bool] = False
|
__filter_restricted__: ClassVar[bool] = False
|
||||||
|
|||||||
Reference in New Issue
Block a user