table.drop() raises ProgrammingError in SQLAlchemy 0.7 instead of SQLError (addresses #112)

This commit is contained in:
Jan Dittberner 2011-05-25 16:53:02 +02:00
parent 20df98c44d
commit 2836390634

View File

@ -11,6 +11,7 @@ from sqlalchemy import exceptions as sa_exceptions
from sqlalchemy.sql import bindparam from sqlalchemy.sql import bindparam
from migrate import exceptions from migrate import exceptions
from migrate.changeset import SQLA_07
from migrate.versioning import genmodel, schemadiff from migrate.versioning import genmodel, schemadiff
from migrate.versioning.repository import Repository from migrate.versioning.repository import Repository
from migrate.versioning.util import load_model from migrate.versioning.util import load_model
@ -57,6 +58,12 @@ class ControlledSchema(object):
""" """
Remove version control from a database. Remove version control from a database.
""" """
if SQLA_07:
try:
self.table.drop()
except sa_exceptions.ProgrammingError:
raise exceptions.DatabaseNotControlledError(str(self.table))
else:
try: try:
self.table.drop() self.table.drop()
except (sa_exceptions.SQLError): except (sa_exceptions.SQLError):