error flushing database after app_loading tests (DB-specific)
|Reported by:||Karen Tracey||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If you try to run the app_loading tests along with any doctests that flush the database after r12982 on a database that creates sequences for AutoFields (e.g. postgres), an error occurs during flush:
Installed 23 object(s) from 1 fixture(s) Models module can be loaded from an app in an egg ... ok Loading an app from an egg that has no models returns no models (and no error) ... ok Models module can be loaded from an app located under an egg's top-level package ... ok Loading an app with no models from under the top-level egg package generates no error ... ok Loading an app from an egg that has an import error in its models module raises that error ... ok Doctest: regressiontests.app_loading.tests.__test__.API_TESTS ... ok Doctest: modeltests.aggregation.models.__test__.API_TESTS ... Error: Database test_postgres couldn't be flushed. Possible reasons: * The database isn't running or isn't configured correctly. * At least one of the expected database tables doesn't exist. * The SQL was invalid. Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run. The full error: relation "app_with_models_ham_id_seq" does not exist LINE 1: SELECT setval('"app_with_models_ham_id_seq"', 1, false); ^ FAIL ====================================================================== FAIL: Doctest: modeltests.aggregation.models.__test__.API_TESTS ---------------------------------------------------------------------- Traceback (most recent call last): ..etc...
The app_loading tests manually load models modules from eggs; this seems to be having some side-effect in the app cache/models datastructures that is making a subsequent flush attempt think that some sequence table must have been created for the loaded model, but it has not (the models module is just loaded, no DB sync is done for it). For the life of me I cannot figure out how to save/restore the appropriate datastructures in the EggLoadingTest setup/teardown to avoid this side-effect. I suppose I could change the models modules in the eggs to not have any AutoFields, so that there would be no need for any sequences, but it would seem to be cleaner to properly clean up in the test. Can someone with more of a clue with the app cache code suggest how to clean up after manually loading a models module?
Change History (8)
comment:3 Changed 7 years ago by
|Component:||Uncategorized → Database layer (models, ORM)|
|Triage Stage:||Unreviewed → Accepted|