[Dbix-class] Mixins/roles with relations

Robert Rothenberg robrwo at gmail.com
Fri Nov 6 15:04:49 GMT 2020


Is it possible to write a DBIC result class that loads a shared 
component or mixin/role that defines a column and relation, e.g. 
something like

__PACKAGE__->add_column( "foobar_id",   { data_type => "integer", 
is_foreign_key => 1 } ); __PACKAGE__->belongs_to( "foobar", 
"My::Schema::Result::Foobar", { "id" => "foobar_id" } ); so that this 
code can be reused in other results? I've experimented with treating 
this as a component or parent class but get errors: Can't locate object 
method "result_source_instance" Is there a way to defer running 
"belongs_to" until after a result source is specified?




More information about the DBIx-Class mailing list