When using the new () method for a DBIx :: Class ResultSource data source to create a (potentially temporary) variable, it does not seem to populate the attributes with the default values specified in the DBIC schema (which we specified to create a table from this schema).
We are currently creating one default value for one such class (the first time this was a problem) with
sub new {
my $class = shift;
my $self = $class->next::method(@_);
$self->queue('DEFAULT_QUEUE_VAL') unless $self->queue();
return $self;
}
in this class (i.e., in the attribute queue => DEFAULT_QUEUE_VAL). However, in the long run, we have several DBIC classes that have different default values, and we would like to avoid repeating the above logic for all the different cases.
Are there CPAN modules / plugins for this? We did not see in our (admittedly, cursory) CPAN search.
Edit: fixed some garbage in the sample code; it turns out i cp'd from outdated code.
source
share