Introductory Relationships in DBIx :: Class

I have several DBIx :: Class :: Core objects that model various database tables.

For some of these models (those that have a queue column), I have another class that introduces subs (mainly to "move" a model object along its queue states).

I would also like this class to introduce has_manyala relationships

class($name)->has_many('queue_history','MySchema::Result::QueueHistory',
 { 'foreign.record_id'=>'self.id' },
 { where => { type => $name }} );

but I can’t get the relationship to register correctly (keep getting the error “No such relationship,” however, when you call the relationship method, the connection returns in the sources).

Any clues as to what is wrong?

+3
source share
1 answer

, :

$class = $schema->class($name)->has_many('queue_history','MySchema::Result::QueueHistory',
 { 'foreign.record_id'=>'self.id' },
 { where => { type => $name }} );

$schema->unregister_source($name);
$schema->register_class($name,$class);

- /, , has_many.

+2

Source: https://habr.com/ru/post/1742515/


All Articles