简体   繁体   English

使用UUID的Flask-Appbuilder模型关系

[英]Flask-Appbuilder Model Relations Using UUID

I'm working on an application which will be defining several models that will be using the UUIDType from scqlalchemy_utils package, defining views like this: 我正在开发一个应用程序,它将定义几个模型,这些模型将使用来自scqlalchemy_utils包的UUIDType,并定义如下视图:

class ChildModelAView(ModelView):
    datamodel = SQLAInterface(ChildA)
    list_columns = ['title', 'description', 'parent_model']

class ChildModelBView(ModelView):
    datamodel = SQLAInterface(ChildB)
    list_columns = ['title', 'description', 'parent_model']

class ParentModelView(ModelView):
    datamodel = SQLAInterface(Parent)
    related_views = [ChildModelAView, ChildModelBView]

And my models like this: 我的模型是这样的:

class ChildA(Model):
    id = Column(UUIDType(binary=False), default=uuid.uuid4, primary_key=True)
    parent_id = Column(UUIDType(binary=False), ForeignKey('parent.id'), nullable=False)
    parent = relationship('Parent')


class ChildB(Model):
    id = Column(UUIDType(binary=False), default=uuid.uuid4, primary_key=True)
    parent_id = Column(UUIDType(binary=False), ForeignKey('parent.id'), nullable=False)
    parent = relationship('Parent')

class Parent(Model):
    id = Column(UUIDType(binary=False), default=uuid.uuid4, primary_key=True)

I see this warning for all the columns defined as a UUID when starting the application: 启动应用程序时,对于所有定义为UUID的列,都会看到此警告:

2018-02-02 19:08:39,244:WARNING:flask_appbuilder.models.filters:Filter type not supported for column: id
2018-02-02 19:08:39,244:WARNING:flask_appbuilder.models.filters:Filter type not supported for column: parent_id

Can anyone show me a working example or snippet that allows filtering with a UUID type (or other custom) column? 谁能给我展示一个允许使用UUID类型(或其他自定义)列进行过滤的有效示例或摘要? Everything else using this type seems to work correctly. 其他所有使用此类型的东西似乎都能正常工作。

Thanks! 谢谢!

In case anyone else stumbles upon this same issue, there seems to be a solution in the works for FAB itself. 万一有其他人偶然发现同一问题,FAB本身的工作似乎可以解决。

Here's the PR that should resolve this problem: https://github.com/dpgaspar/Flask-AppBuilder/pull/694 这是应该解决此问题的PR: https : //github.com/dpgaspar/Flask-AppBuilder/pull/694

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM