在 Google App Engine 中将模型转换为 PolyModel

发布于 2024-12-16 23:00:27 字数 134 浏览 3 评论 0原文

如果在数据存储中已存储实体后将模型的基类从 db.Model 切换到 db.PolyModel(您决定要添加多态性),会产生什么后果?

另外,是否有任何理由不总是将模型创建为 PolyModel,以便子类化永远不是问题?

What are the consequences if you switch a model's base class from db.Model to db.PolyModel (You decide you want to add polymorphism) after it already has entities stored in the datastore?

Also, is there any reason not to always create your models as PolyModels, so subclassing is never an issue?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黒涩兲箜 2024-12-23 23:00:28

至于您的第一个问题,这似乎不是问题,因为更改模式基础class 是 Google 记录的删除属性的方法。

我相信 PolyModel 在访问属性时有一些隐藏成本,这就是为什么您应该从模型开始并仅在必要时进行切换。

As for you for your first question, it doesn't seem like an issue, since changing modal base class is a documented way to remove properties by Google.

I believe that PolyModel has some hidden cost when accessing the properties, this is why you should start with Model and switch only if necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文