fix: use == operator instead of is_ for sql queries (#1453)

This commit is contained in:
Hayden 2022-06-26 12:42:13 -08:00 committed by GitHub
parent f96a584a5d
commit 157bad0e29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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,
),
)

View File

@ -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)))