Fixed SQLAlchemy bug