qizhiyi / sqlalchemy-migrate

Automatically exported from code.google.com/p/sqlalchemy-migrate
MIT License
0 stars 0 forks source link

Misleading MigrateDeprecationWarning in case you have a TypeError bug in your upgrade/downgrade functions #106

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've encountered a problem with the following code (in 
migrate/versioning/py.py):

---
try:
            script_func(engine)
        except TypeError:
            warnings.warn("upgrade/downgrade functions must accept engine"
                " parameter (since version > 0.5.4)", exceptions.MigrateDeprecationWarning)
            raise

---

The try/except clause is not the proper way to detect if the upgrade/downgrade 
functions accept a parameter or not. If you make a mistake somewhere in one of 
these function that raises a TypeError, you get the misleading 
MigrateDeprecationWarning instead of a clear failure. I guess it would be 
better to check the signature by introspection in this particular case.

Example that triggers the misleading error:
def upgrade(migration_engine)
  raise TypeError()  # oops, I have a bug in my upgrade code

Original issue reported on code.google.com by sylvain....@gmail.com on 4 Dec 2010 at 11:18

GoogleCodeExporter commented 8 years ago
I agree:) Fixed in c12436581f77

Original comment by iElect...@gmail.com on 5 Feb 2011 at 1:20