Don't use error handling to determine if tables exist.

Review Request #11236 — Created Oct. 20, 2020 and submitted — Latest diff uploaded

Information

Django Evolution
master

Reviewers

When Evolver sets itself up, it looks for the presence of a Version
table, falling back on bootstrapping if it doesn't exist. This was done
by attempting a direct query and then initiating bootstrap if no
Version items were present or if the table itself didn't exist in the
database.

Handling this by watching for an error isn't ideal, and can impact any
parent transaction, or obscure other issues. Instead, the better
approach is to look to see if the table exists in the database directly.

This change implements that, and takes care of a similar type of check
in one of the Evolver unit tests.

Unit tests pass for all databases.

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
Don't use error handling to determine if tables exist.
When `Evolver` sets itself up, it looks for the presence of a `Version` table, falling back on bootstrapping if it doesn't exist. This was done by attempting a direct query and then initiating bootstrap if no `Version` items were present or if the table itself didn't exist in the database. Handling this by watching for an error isn't ideal, and can impact any parent transaction, or obscure other issues. Instead, the better approach is to look to see if the table exists in the database directly. This change implements that, and takes care of a similar type of check in one of the `Evolver` unit tests.
ac6ca2ed200c399c2c30d51e39b4fef11e23ad82 Christian Hammond
django_evolution/evolve.py
django_evolution/tests/test_evolver.py
Loading...