在 DBIx::Class 中注入关系
我有一些 DBIx::Class::Core 对象,用于对各种数据库表进行建模。
对于其中一些模型(具有“队列”列的模型),我有另一个类注入子对象(基本上,沿着其队列状态“移动”模型对象)。
我还想让该类注入 has_many
关系,
class($name)->has_many('queue_history','MySchema::Result::QueueHistory',
{ 'foreign.record_id'=>'self.id' },
{ where => { type => $name }} );
但我似乎无法正确注册关系(不断收到“没有这样的关系”错误 - 但是,在调用关系方法时来源提供了关系)。
有什么线索表明出了什么问题吗?
I have a handful of DBIx::Class::Core objects that model various database tables.
For some of those models (those that have a 'queue' column), I have another class inject subs (basically, to 'move' the model object along it's queue states).
I'd like to also have that class inject has_many
relationships ala
class($name)->has_many('queue_history','MySchema::Result::QueueHistory',
{ 'foreign.record_id'=>'self.id' },
{ where => { type => $name }} );
but I can't seem to get the relationships to register properly (keep getting "No Such Relationship" errors - however, when calling the relationship method on the sources provides back the relationship).
Any clues as to what's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番研究后,发现以下方法有效:
关键是取消注册/注册方法,以便生成通过新的
has_many
关系添加的所有适当的其他方法。After some digging around, the following works:
The key being the unregister/register methods in order to generate all the appropriate other methods that get added by having a new
has_many
relationship.