attributeError:' mapper'从SQLalchemy 1.3更新到1.4后,对象没有属性

发布于 2025-02-13 12:41:03 字数 830 浏览 0 评论 0原文

我在这里与sqlalchemy 1.4有问题。

使用sqlalchemy 1.3,调用别名工作,但是

    def query(self, patient_id):
        cls = self.__class__
        checkin = aliased(cls.relationship_one)
        study = aliased(checkin.relationship_two)

        # A query is done here
        # Omitted for brevity
        return result

,如果我将sqlalchemy更新为1.4我得到以下错误

attributeError :'mapper'对象没有属性'relatess_two'


在更新和使用参考列的属性之后,我遇到了一些类似的错误,

alias = aliased(cls.relationship_1)
alias.my_column

但我通过感谢

alias.c.my_column # Note the .c here

您的任何帮助

I'm having an issue here with SQLAlchemy 1.4.

With SQLAlchemy 1.3, the calls to aliased work, like this

    def query(self, patient_id):
        cls = self.__class__
        checkin = aliased(cls.relationship_one)
        study = aliased(checkin.relationship_two)

        # A query is done here
        # Omitted for brevity
        return result

However, if I updated SQLAlchemy to 1.4 I get the following error

AttributeError: 'Mapper' object has no attribute 'relationship_two'


I've gotten some similar errors after updating and using attributes referring to columns like

alias = aliased(cls.relationship_1)
alias.my_column

But I fixed it by using

alias.c.my_column # Note the .c here

Thanks for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文