Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bump SQLAlchemy #3196

Merged
8 changes: 3 additions & 5 deletions mealie/db/models/group/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ class Group(SqlAlchemyBase, BaseMixins):
name: Mapped[str] = mapped_column(sa.String, index=True, nullable=False, unique=True)
slug: Mapped[str | None] = mapped_column(sa.String, index=True, unique=True)
users: Mapped[list["User"]] = orm.relationship("User", back_populates="group")
categories: Mapped[Category] = orm.relationship(
Category, secondary=group_to_categories, single_parent=True, uselist=True
)
categories: Mapped[list[Category]] = orm.relationship(Category, secondary=group_to_categories, single_parent=True)

invite_tokens: Mapped[list[GroupInviteToken]] = orm.relationship(
GroupInviteToken, back_populates="group", cascade="all, delete-orphan", uselist=True
GroupInviteToken, back_populates="group", cascade="all, delete-orphan"
)
preferences: Mapped[GroupPreferencesModel] = orm.relationship(
GroupPreferencesModel,
Expand All @@ -51,7 +49,7 @@ class Group(SqlAlchemyBase, BaseMixins):
)

# Recipes
recipes: Mapped[list["RecipeModel"]] = orm.relationship("RecipeModel", back_populates="group", uselist=True)
recipes: Mapped[list["RecipeModel"]] = orm.relationship("RecipeModel", back_populates="group")

# CRUD From Others
common_args = {
Expand Down
4 changes: 2 additions & 2 deletions mealie/db/models/group/mealplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class GroupMealPlanRules(BaseMixins, SqlAlchemyBase):
String, nullable=False, default=""
) # "breakfast", "lunch", "dinner", "side"

categories: Mapped[Category] = orm.relationship(Category, secondary=plan_rules_to_categories, uselist=True)
tags: Mapped[list[Tag]] = orm.relationship(Tag, secondary=plan_rules_to_tags, uselist=True)
categories: Mapped[list[Category]] = orm.relationship(Category, secondary=plan_rules_to_categories)
tags: Mapped[list[Tag]] = orm.relationship(Tag, secondary=plan_rules_to_tags)

@auto_init()
def __init__(self, **_) -> None:
Expand Down
4 changes: 2 additions & 2 deletions mealie/db/models/group/shopping_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ class ShoppingList(SqlAlchemyBase, BaseMixins):
group: Mapped["Group"] = orm.relationship("Group", back_populates="shopping_lists")

name: Mapped[str | None] = mapped_column(String)
list_items: Mapped[ShoppingListItem] = orm.relationship(
list_items: Mapped[list[ShoppingListItem]] = orm.relationship(
ShoppingListItem,
cascade="all, delete, delete-orphan",
order_by="ShoppingListItem.position",
collection_class=ordering_list("position"),
)

recipe_references: Mapped[ShoppingListRecipeReference] = orm.relationship(
recipe_references: Mapped[list[ShoppingListRecipeReference]] = orm.relationship(
ShoppingListRecipeReference, cascade="all, delete, delete-orphan"
)
label_settings: Mapped[list["ShoppingListMultiPurposeLabel"]] = orm.relationship(
Expand Down
4 changes: 2 additions & 2 deletions mealie/db/models/recipe/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
user_id: Mapped[GUID | None] = mapped_column(GUID, sa.ForeignKey("users.id", use_alter=True), index=True)
user: Mapped["User"] = orm.relationship("User", uselist=False, foreign_keys=[user_id])

meal_entries: Mapped["GroupMealPlan"] = orm.relationship(
meal_entries: Mapped[list["GroupMealPlan"]] = orm.relationship(
"GroupMealPlan", back_populates="recipe", cascade="all, delete-orphan"
)

Expand All @@ -72,7 +72,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
recipe_yield: Mapped[str | None] = mapped_column(sa.String)
recipeCuisine: Mapped[str | None] = mapped_column(sa.String)

assets: Mapped[RecipeAsset] = orm.relationship("RecipeAsset", cascade="all, delete-orphan")
assets: Mapped[list[RecipeAsset]] = orm.relationship("RecipeAsset", cascade="all, delete-orphan")
nutrition: Mapped[Nutrition] = orm.relationship("Nutrition", uselist=False, cascade="all, delete-orphan")
recipe_category: Mapped[list["Category"]] = orm.relationship(
"Category", secondary=recipes_to_categories, back_populates="recipes"
Expand Down
8 changes: 6 additions & 2 deletions mealie/schema/group/group_shopping_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,14 @@ class ShoppingListUpdate(ShoppingListSave):


class ShoppingListOut(ShoppingListUpdate):
recipe_references: list[ShoppingListRecipeRefOut]
label_settings: list[ShoppingListMultiPurposeLabelOut]
recipe_references: list[ShoppingListRecipeRefOut] = []
label_settings: list[ShoppingListMultiPurposeLabelOut] = []
hay-kot marked this conversation as resolved.
Show resolved Hide resolved
model_config = ConfigDict(from_attributes=True)

@field_validator("recipe_references", "label_settings", mode="before")
def default_none_to_empty_list(cls, v):
return v or []

@classmethod
def loader_options(cls) -> list[LoaderOption]:
return [
Expand Down
103 changes: 56 additions & 47 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading