After adding a few recipes that had ingredients not in the standard set, I expected to be able to use them in other recipes. But when creating a new recipe my new ingredients are not available, either to auto-complete or in the drop down for "Ingredient (key)".
These seem to be coming from the "shopcats" table, and my new ingredients have been added to the table, but the drop down for "Ingredient (key)" does not show them.
Or do I have this all wrong?
I should have said:
It's not the shopcats table you're worried about, but this bug report makes sense inasmuch as ingredient key entry was re-implemented in 0.14.5, so it's quite likely a new bug got introduced.
If you quit Gourmet and re-open, do your keys show up in completion? (this isn't a work around, just a diagnostic to help me zero in on the bug :)
Tried that but no good. The keys don't show up even after a restart.
If these values are not from the shopcats table where are they from?
"Source" has a similar problem, but new sources do show up after a restart.
I guessing (after taking a quick look at the code) that new items will never be added to the completion list during a single run because add_ing() is commented out.
I also can't find where add_ing_hooks is ever run (I'm assuming that all the code un legacy_db is not used).
But that doesn't explain why the new keys are not showing up after a restart. Still digging.
The ingredient keys are stored in the ingredients table.
The shopcats table stores a list of associations:
ingredient key -> shopping category
The thing to look for is where the combo box in question gets its list of ingredient keys from...
What code are you looking at where add_ing is commented out?
OH -- and you're right -- the legacy_db stuff is all just there for updates (it's needed to read old databases so we can convert them to new databases).
key_model holds the list used by the combo box.
reccard.py:make_key_model() initializes this list from the "keylookup" table.
neither key_model nor the "keylookup" table are updated when a new ingredient is added.
key_model would be updated if reccard.py:add_ing() was not commented out.
But there is no code to update the "keylookup" table so these values could be used again the next time the program is run. A call to backends/db.py:add_ing_to_keydic() should probably be added to add_ing().
So, I believe the fix is:
- uncomment the code in add_ing()
- add a call to add_ing_to_keydic() to add_ing()
Although I am taking it on faith that add_ing() is ever run because I haven't found anywhere add_ing_hooks is used.
The bit about add_ing_to_keydic() could be wrong.
There is a call to backends/db.py:add_ing_and_update_keydic() in reccard.py:commit_ingredients() which should do the trick, but it's not. The keylookup table in my database does not have any of the new ingredients in it.
Confirmed that uncommenting the code in reccard:add_ing() causes the ingredient key auto-completion to work during a single run.
I'm still not sure when the keylookup table gets updated. Some of my new ingredients are there and some aren't. The ones that don't make it don't show up in auto-completion in future runs.
It would be nice if we had a fix_database program that can fix up the keylookup table with all the ingredients in the ingredients table.
I may take a stab at this, but my python is rudimentary at best.
Log in to post a comment.