-
-
Notifications
You must be signed in to change notification settings - Fork 899
Closed
Description
Hi,
First of all congrats on the new release! This will allow us to go back to a pinned version of flask-sqlalchemy instead of the master branch 👍
On the other hand, the change #467 now generates this stack-trace in the Flask-AppBuilder project which I would need some help investigating to be able to use release 2.2 directly:
12:48:03 File "/src/<module_name>/models.py", line 10, in <module>
12:48:03 from flask_appbuilder.security.sqla.models import User
12:48:03 File "/usr/local/lib/python2.7/dist-packages/flask_appbuilder/security/sqla/models.py", line 12, in <module>
12:48:03 class Permission(Model):
12:48:03 File "/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py", line 602, in __init__
12:48:03 DeclarativeMeta.__init__(self, name, bases, d)
12:48:03 File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/api.py", line 55, in __init__
12:48:03 _as_declarative(cls, classname, cls.__dict__)
12:48:03 File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/base.py", line 88, in _as_declarative
12:48:03 _MapperConfig.setup_mapping(cls, classname, dict_)
12:48:03 File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/base.py", line 103, in setup_mapping
12:48:03 cfg_cls(cls_, classname, dict_)
12:48:03 File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/base.py", line 133, in __init__
12:48:03 self._setup_inheritance()
12:48:03 File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/base.py", line 429, in _setup_inheritance
12:48:03 "table-mapped class." % cls
12:48:03 InvalidRequestError: Class <class 'flask_appbuilder.security.sqla.models.Permission'> does not have a __table__ or __tablename__ specified and does not inherit from an existing table-mapped class.
The error message contradicts the model declaration as it does have a __tablename
defined:
class Permission(Model):
__tablename__ = 'ab_permission'
id = Column(Integer, Sequence('ab_permission_id_seq'), primary_key=True)
name = Column(String(100), unique=True, nullable=False)
def __repr__(self):
return self.name
I understand that this change is related to the @declared_attr
decorator but despite reading http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/api.html#api-reference I don't really know exactly how I should apply it to the model.
Thanks for your help