mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-29 05:25:30 -05:00
Bug/error relating units foods (#987)
* fix type guard * update typing * rearrange methods * spelling * fix unknown error response * update type check for none types * add discord notification
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from functools import wraps
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from sqlalchemy.orm import MANYTOMANY, MANYTOONE, ONETOMANY, Session
|
||||
@@ -170,9 +171,13 @@ def auto_init(): # sourcery no-metrics
|
||||
if val is None:
|
||||
raise ValueError(f"Expected 'id' to be provided for {key}")
|
||||
|
||||
if isinstance(val, (str, int)):
|
||||
if isinstance(val, (str, int, UUID)):
|
||||
instance = session.query(relation_cls).filter_by(**{get_attr: val}).one_or_none()
|
||||
setattr(self, key, instance)
|
||||
else:
|
||||
# If the value is not of the type defined above we assume that it isn't a valid id
|
||||
# and try a different approach.
|
||||
pass
|
||||
|
||||
elif relation_dir == MANYTOMANY:
|
||||
instances = handle_many_to_many(session, get_attr, relation_cls, val)
|
||||
|
||||
@@ -142,7 +142,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
||||
assets: list = None,
|
||||
notes: list[dict] = None,
|
||||
nutrition: dict = None,
|
||||
recipe_ingredient: list[str] = None,
|
||||
recipe_ingredient: list[dict] = None,
|
||||
settings: dict = None,
|
||||
**_,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user