mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-15 14:27:31 -04:00
re-implement PrivateColumn to make sqlalchemy happy
This commit is contained in:
@@ -14,11 +14,15 @@ from ._model_utils.datetime import NaiveDateTime, get_utc_now
|
||||
NORMALIZE_PUNCTUATION = string.punctuation.replace("'", "").replace('"', "")
|
||||
_NORMALIZE_PUNCTUATION_TABLE = str.maketrans(NORMALIZE_PUNCTUATION, " " * len(NORMALIZE_PUNCTUATION))
|
||||
|
||||
type PrivateColumn[T] = Mapped[Annotated[T, mapped_column(info={"private": True})]]
|
||||
"""
|
||||
A `Mapped` attribute with metadata `private=True`.
|
||||
Signals to the query filter API not to allow using this field in query operations.
|
||||
"""
|
||||
|
||||
class PrivateColumn[T]:
|
||||
"""
|
||||
Drop-in replacement for `Mapped[]` that marks a column as private.
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user