mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
potentially fixes #216
This commit is contained in:
parent
c0b774db24
commit
ac76413563
2 changed files with 8 additions and 11 deletions
|
@ -1,9 +1,9 @@
|
|||
import sqlalchemy as sa
|
||||
import sqlalchemy.orm as orm
|
||||
from fastapi.logger import logger
|
||||
from mealie.core.config import DEFAULT_GROUP
|
||||
from mealie.db.models.model_base import BaseMixins, SqlAlchemyBase
|
||||
from mealie.db.models.recipe.category import Category, group2categories
|
||||
from fastapi.logger import logger
|
||||
from sqlalchemy.orm.session import Session
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Group(SqlAlchemyBase, BaseMixins):
|
|||
# Webhook Settings
|
||||
webhook_enable = sa.Column(sa.Boolean, default=False)
|
||||
webhook_time = sa.Column(sa.String, default="00:00")
|
||||
webhook_urls = orm.relationship("WebhookURLModel", uselist=True, cascade="all, delete")
|
||||
webhook_urls = orm.relationship("WebhookURLModel", uselist=True, cascade="all, delete-orphan")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -52,7 +52,6 @@ class Group(SqlAlchemyBase, BaseMixins):
|
|||
self.webhook_urls = [WebhookURLModel(url=x) for x in webhook_urls]
|
||||
|
||||
def update(self, session: Session, *args, **kwargs):
|
||||
self._sql_remove_list(session, [WebhookURLModel], self.id)
|
||||
|
||||
self.__init__(session=session, *args, **kwargs)
|
||||
|
||||
|
|
|
@ -32,19 +32,19 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
|||
cookTime = sa.Column(sa.String)
|
||||
recipeYield = sa.Column(sa.String)
|
||||
recipeCuisine = sa.Column(sa.String)
|
||||
tool: List[Tool] = orm.relationship("Tool", cascade="all, delete")
|
||||
nutrition: Nutrition = orm.relationship("Nutrition", uselist=False, cascade="all, delete")
|
||||
tool: List[Tool] = orm.relationship("Tool", cascade="all, delete-orphan")
|
||||
nutrition: Nutrition = orm.relationship("Nutrition", uselist=False, cascade="all, delete-orphan")
|
||||
recipeCategory: List = orm.relationship("Category", secondary=recipes2categories, back_populates="recipes")
|
||||
|
||||
recipeIngredient: List[RecipeIngredient] = orm.relationship(
|
||||
"RecipeIngredient",
|
||||
cascade="all, delete",
|
||||
cascade="all, delete-orphan",
|
||||
order_by="RecipeIngredient.position",
|
||||
collection_class=ordering_list("position"),
|
||||
)
|
||||
recipeInstructions: List[RecipeInstruction] = orm.relationship(
|
||||
"RecipeInstruction",
|
||||
cascade="all, delete",
|
||||
cascade="all, delete-orphan",
|
||||
order_by="RecipeInstruction.position",
|
||||
collection_class=ordering_list("position"),
|
||||
)
|
||||
|
@ -53,10 +53,10 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
|||
slug = sa.Column(sa.String, index=True, unique=True)
|
||||
tags: List[Tag] = orm.relationship("Tag", secondary=recipes2tags, back_populates="recipes")
|
||||
dateAdded = sa.Column(sa.Date, default=date.today)
|
||||
notes: List[Note] = orm.relationship("Note", cascade="all, delete")
|
||||
notes: List[Note] = orm.relationship("Note", cascade="all, delete-orphan")
|
||||
rating = sa.Column(sa.Integer)
|
||||
orgURL = sa.Column(sa.String)
|
||||
extras: List[ApiExtras] = orm.relationship("ApiExtras", cascade="all, delete")
|
||||
extras: List[ApiExtras] = orm.relationship("ApiExtras", cascade="all, delete-orphan")
|
||||
|
||||
@validates("name")
|
||||
def validate_name(self, key, name):
|
||||
|
@ -145,8 +145,6 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
|||
extras: dict = None,
|
||||
):
|
||||
"""Updated a database entry by removing nested rows and rebuilds the row through the __init__ functions"""
|
||||
list_of_tables = [RecipeIngredient, RecipeInstruction, ApiExtras, Tool]
|
||||
RecipeModel._sql_remove_list(session, list_of_tables, self.id)
|
||||
|
||||
self.__init__(
|
||||
session=session,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue