[Dbix-class] Idea for DBIx::Class::DynamicDefault

Bernhard Graf dbic3 at augensalat.de
Mon Oct 20 22:37:17 BST 2008


This request is addressed mainly to the authour Florian Ragwitz, but of 
course every one else is invited to comment on this.

DBIx::Class::DynamicDefault is nice, because it can be used as base for 
many other DBIC components.

I'm missing one thing though:
While in add_columns() arbitrary methods can be assigned to every column 
with the options 'dynamic_default_on_create' 
and 'dynamic_default_on_update', the methods itself have to be "column 
agnostic". However I can imagine situations where it would be 
desireable for such a method to know about the meta data of the column 
it acts for, like data type or field size.

So why not giving the column name to the method?
This would require only a tiny change in 
DBIx::Class::DynamicDefault::insert() by changing the line

   my $default_value = $self->$meth;

to 

   my $default_value = $self->$meth($column_name);

Now the called method could obtain the column's meta data by calling 
$self->column_info($column_name) .
-- 
Bernhard Graf



More information about the DBIx-Class mailing list