【问题标题】:Can the ClassTableInheritance plugin for Sequel be configured to store something other than the model name as the key?可以将 Sequel 的 ClassTableInheritance 插件配置为存储模型名称以外的其他内容作为键吗?
【发布时间】:2014-05-26 14:14:42
【问题描述】:

我在我的项目中使用class_table_inheritance Sequel plugin,我有以下型号:

class Account < Sequel::Model
  plugin :class_table_inheritance
end

class TwitterAccount < Account; end
class FacebookAccount < Account; end
class GoogleAccount < Account; end

我希望在我的 Account 表中设置一个名为“account_type”的列,该列是一个枚举,其可能的值是“Twitter”、“Facebook”和“Google”,以识别帐户的类型。

我不喜欢我的表中的列与我的模型类的名称相关联的想法。它直接将我与我正在使用的 ORM 联系起来,并防止更改模型名称。

有没有办法向 class_table_inheritance 插件提供符号到类名符号的键映射,就像可以提供类名符号到表名符号的表映射一样?

【问题讨论】:

    标签: ruby orm sequel class-table-inheritance


    【解决方案1】:

    目前,class_table_inheritance 插件不支持此类功能(与single_table_inheritance 插件不同)。添加对此类功能的支持应该不难,我会看看我是否可以尽快处理。

    【讨论】:

    猜你喜欢
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-24
    • 1970-01-01
    • 2018-01-10
    • 1970-01-01
    相关资源
    最近更新 更多