Closed mattiasmaahl closed 3 years ago
Do we use a different copy of the DB file for testing?
I don't think we do actually, or rather, we may do as we set the "application name" to be "brewtarget-test" that should store all application files in its own folder, but I have never seen the db there. Could be that wen may have to do a restore default to get a new/fresh db there.
I'll have a look.
Yeah so I checked, there is a database.sqlite created in the
EDIT: remembered the default db file name wrong. :smile:
so here are the logs from where it crashes in the tests: [11:22:21.132] DEBUG : Creating new Hop: cascade_4pct = Database::instance().newHop();, in 93 [11:22:21.132] DEBUG : T Database::newNamedEntity(QHash<int, T>) [with T = Hop] SELECT SQL: "SELECT FROM hop WHERE id = 136", in 172 [11:22:21.132] DEBUG : Recipe Database::getParentRecipe(const NamedEntity) NamedEntity in recipe search: "SELECT recipe_id AS id FROM hop_in_recipe WHERE hop_id=136", in 1116 [11:22:21.132] ERROR : void Database::updateEntry(NamedEntity, QString, QVariant, bool, bool) Could not translate "inventoryId" to a column name, in 3118 [11:22:21.132] ERROR : "Hop Database::newHop(Hop*, bool) Could not translate inventoryId to a column name", in 1744
So there is a thing with the inventoryId. I just checked that the default_db.sqlite also has the inventory_id column in the Hop Table, so something is happening in the code? @matty0ung any thoughts on this? you and @mikfire are the ones more read up on these parts of the code.
Also, I may be way out on a wild goose chase deep in parts where there is no error and the solution probably is simple. if so, don't be afraid do call me out on it! :smile:
Ah, interesting. Yes, I wouldn't have seen this in Brewken because of the different database layer. What happens if you edit line 87 of TableSchemaConst.h to say "inventoryId"
instead of "inventory_id"
? (Or, failing that, change "inventoryId"
to "inventory_id"
on line 26 of model/NamedEntityWithInventory.h.)
Interesting, I will check in just a moment.
So tested both ways and found that both solutions work.
do you have a preferred solution given that this somewhat plays into your work with DB overhaul?
So I have been going though the debugging for the test and found that when the
cascade_4pct = Database::instance().newHop();
or thetwoRow = Database::instance().newFermentable();
gets called the tests fail.I have narrowed it down to the call to return
Database::instance().modifyEntry(this, prop_name, value);
in NamedEntity.cpp:390A theory is that when we are running the tests Brewtarget tries to add entries to the inventory, but that is just a theory at this point, I'm still investigating how, according to my limited mind, we do this best in the testing scenario.