mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 13:35:23 +02:00
fix: Migration Issue With Duplicate Labels (#3085)
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
* fixed eager queries * test --------- Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
This commit is contained in:
parent
c3f7ad8954
commit
7947aa99ae
4 changed files with 35 additions and 5 deletions
|
@ -59,7 +59,12 @@ def _resolve_duplicate_food(
|
|||
keep_food_id: UUID4,
|
||||
dupe_food_id: UUID4,
|
||||
):
|
||||
for shopping_list_item in session.query(ShoppingListItem).filter_by(food_id=dupe_food_id).all():
|
||||
for shopping_list_item in (
|
||||
session.query(ShoppingListItem)
|
||||
.options(load_only(ShoppingListItem.id, ShoppingListItem.food_id))
|
||||
.filter_by(food_id=dupe_food_id)
|
||||
.all()
|
||||
):
|
||||
shopping_list_item.food_id = keep_food_id
|
||||
|
||||
for recipe_ingredient in (
|
||||
|
@ -82,10 +87,20 @@ def _resolve_duplicate_unit(
|
|||
keep_unit_id: UUID4,
|
||||
dupe_unit_id: UUID4,
|
||||
):
|
||||
for shopping_list_item in session.query(ShoppingListItem).filter_by(unit_id=dupe_unit_id).all():
|
||||
for shopping_list_item in (
|
||||
session.query(ShoppingListItem)
|
||||
.options(load_only(ShoppingListItem.id, ShoppingListItem.unit_id))
|
||||
.filter_by(unit_id=dupe_unit_id)
|
||||
.all()
|
||||
):
|
||||
shopping_list_item.unit_id = keep_unit_id
|
||||
|
||||
for recipe_ingredient in session.query(RecipeIngredientModel).filter_by(unit_id=dupe_unit_id).all():
|
||||
for recipe_ingredient in (
|
||||
session.query(RecipeIngredientModel)
|
||||
.options(load_only(RecipeIngredientModel.id, RecipeIngredientModel.unit_id))
|
||||
.filter_by(unit_id=dupe_unit_id)
|
||||
.all()
|
||||
):
|
||||
recipe_ingredient.unit_id = keep_unit_id
|
||||
|
||||
session.commit()
|
||||
|
@ -100,10 +115,20 @@ def _resolve_duplicate_label(
|
|||
keep_label_id: UUID4,
|
||||
dupe_label_id: UUID4,
|
||||
):
|
||||
for shopping_list_item in session.query(ShoppingListItem).filter_by(label_id=dupe_label_id).all():
|
||||
for shopping_list_item in (
|
||||
session.query(ShoppingListItem)
|
||||
.options(load_only(ShoppingListItem.id, ShoppingListItem.label_id))
|
||||
.filter_by(label_id=dupe_label_id)
|
||||
.all()
|
||||
):
|
||||
shopping_list_item.label_id = keep_label_id
|
||||
|
||||
for ingredient_food in session.query(IngredientFoodModel).filter_by(label_id=dupe_label_id).all():
|
||||
for ingredient_food in (
|
||||
session.query(IngredientFoodModel)
|
||||
.options(load_only(IngredientFoodModel.id, IngredientFoodModel.label_id))
|
||||
.filter_by(label_id=dupe_label_id)
|
||||
.all()
|
||||
):
|
||||
ingredient_food.label_id = keep_label_id
|
||||
|
||||
session.commit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue