Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Merging ingredient doesnt work if referenced by a shopping list #3624

Open
6 tasks done
salco opened this issue May 20, 2024 · 3 comments
Open
6 tasks done

[BUG] - Merging ingredient doesnt work if referenced by a shopping list #3624

salco opened this issue May 20, 2024 · 3 comments
Labels
bug: confirmed bug Something isn't working

Comments

@salco
Copy link

salco commented May 20, 2024

First Check

  • This is not a feature request.
  • I added a very descriptive title to this issue (title field is above this).
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.
  • This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

If you want to merge an ingredient that is already used inside a shopping list nothing is show to the user and it doesnt work.
In reality we get a http response: 500 when we look at the network log.
Also if we look at the database (for me it's postgres) you see that the error is:

[21915] ERROR:  update or delete on table "ingredient_foods" violates foreign key constraint "shopping_list_items_food_id_fkey" on table "shopping_list_items"

To confirm:
I've deleted the shopping list in question and retry the merge and all went well.

Steps to Reproduce

  1. create tomayto and tomato
  2. create 2 recipes, one using tomayto the other using tomato
  3. create a new shopping list: I give you the freedom to find a funny name 😉
  4. use the 2 recipes to add all ingredient to the shopping list
  5. then go to the the option or with the api call direcly api/foods/merge and merge tomayto into tomato

Voila you should get the response 500 in the browser logs.

Please provide relevant logs

2024-05-19 21:46:29.354 EDT [21915] ERROR:  update or delete on table "ingredient_foods" violates foreign key constraint "shopping_list_items_food_id_fkey" on table "shopping_list_items"
2024-05-19 21:46:29.354 EDT [21915] DETAIL:  Key (id)=(※※※※※※※※-※※※※-※※※※-※※※※-※※※※※※※※※※※※) is still referenced from table "shopping_list_items".
2024-05-19 21:46:29.354 EDT [21915] STATEMENT:  DELETE FROM ingredient_foods WHERE ingredient_foods.id = '※※※※※※※※-※※※※-※※※※-※※※※-※※※※※※※※※※※※'::UUID

Mealie Version

1.6.0

Deployment

Docker (Linux)

Additional Deployment Details

Details
Version: v1.6.0
Build: 418a8ec
Mode de l'application: Production
Mode démo: Non démo
Port de l'API: 9000
Documentation de l'API: Activé
Type de base de données: postgres
Version du Scraper de recette: 14.56.0

Checks
Site sécurisé: Oui
URL de base côté serveur: Oui
Prêt pour LDAP: Non
Prêt pour OIDC: Non
Courriel configuré: Non

@salco salco added bug Something isn't working triage labels May 20, 2024
@ChrisLane
Copy link
Contributor

ChrisLane commented May 23, 2024

Just came to post the same bug. I found this when trying to delete Food Data for an item that was in a shopping list.

I think the UI should offer to delete the referencing shopping list entry and perhaps specify which shopping list is referencing the ingredient.

Mealie 1.7.0 for me.

@michael-genson
Copy link
Collaborator

michael-genson commented May 23, 2024

Deleting foods should just work, it shouldn't get caught up by foreign key issues.

Ideally when deleting foods, existing shopping list items are either deleted, or their food is converted to a note before deletion. Ingredients should probably do this too as along as we're adding custom food deletion logic.

@salco
Copy link
Author

salco commented May 24, 2024

But in my case it's not deleting but updating since I'm merging one keyword into another.
If the food is a key can we not just change it for the new one, one way or another?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: confirmed bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants