From 157bad0e2909a74c139867fa9be2b0b475f4862d Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sun, 26 Jun 2022 12:42:13 -0800 Subject: [PATCH] fix: use == operator instead of is_ for sql queries (#1453) --- mealie/repos/repository_meal_plan_rules.py | 8 ++++---- mealie/repos/repository_recipes.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mealie/repos/repository_meal_plan_rules.py b/mealie/repos/repository_meal_plan_rules.py index 4c9e2a777700..a12e83f0bb39 100644 --- a/mealie/repos/repository_meal_plan_rules.py +++ b/mealie/repos/repository_meal_plan_rules.py @@ -15,14 +15,14 @@ class RepositoryMealPlanRules(RepositoryGeneric[PlanRulesOut, GroupMealPlanRules def get_rules(self, day: PlanRulesDay, entry_type: PlanRulesType) -> list[PlanRulesOut]: qry = self.session.query(GroupMealPlanRules).filter( or_( - GroupMealPlanRules.day.is_(day), + GroupMealPlanRules.day == day, GroupMealPlanRules.day.is_(None), - GroupMealPlanRules.day.is_(PlanRulesDay.unset.value), + GroupMealPlanRules.day == PlanRulesDay.unset.value, ), or_( - GroupMealPlanRules.entry_type.is_(entry_type), + GroupMealPlanRules.entry_type == entry_type, GroupMealPlanRules.entry_type.is_(None), - GroupMealPlanRules.entry_type.is_(PlanRulesType.unset.value), + GroupMealPlanRules.entry_type == PlanRulesType.unset.value, ), ) diff --git a/mealie/repos/repository_recipes.py b/mealie/repos/repository_recipes.py index 152a7fdaef2a..b5b50902fbf2 100644 --- a/mealie/repos/repository_recipes.py +++ b/mealie/repos/repository_recipes.py @@ -228,7 +228,7 @@ class RepositoryRecipes(RepositoryGeneric[Recipe, RecipeModel]): if categories: cat_ids = [x.id for x in categories] if require_all_categories: - fltr.extend(RecipeModel.recipe_category.any(Category.id.is_(cat_id)) for cat_id in cat_ids) + fltr.extend(RecipeModel.recipe_category.any(Category.id == cat_id) for cat_id in cat_ids) else: fltr.append(RecipeModel.recipe_category.any(Category.id.in_(cat_ids))) @@ -243,7 +243,7 @@ class RepositoryRecipes(RepositoryGeneric[Recipe, RecipeModel]): tool_ids = [x.id for x in tools] if require_all_tools: - fltr.extend(RecipeModel.tools.any(Tool.id.is_(tool_id)) for tool_id in tool_ids) + fltr.extend(RecipeModel.tags.any(Tag.id == tag_id) for tag_id in tag_ids) else: fltr.append(RecipeModel.tools.any(Tool.id.in_(tool_ids)))