[Dbix-class] DBIx::Class::Index::Simple

Mark Lawrence nomad at null.net
Wed Apr 2 07:42:23 BST 2008


On Tue Apr 01, 2008 at 08:35:38PM -0500, Jonathan Rockway wrote:
> * On Tue, Apr 01 2008, Peter Rabbitson wrote:
> 
> >  __PACKAGE__->add_columns(
> >    id => { data_type => 'integer', is_auto_increment => 1 },
> >    starts_at => { data_type => 'datetime' },
> > -  created_on => { data_type => 'timestamp' }
> > +  created_on => { data_type => 'timestamp', index_as => 'created_test_simple_idx' }
> >  );
> 
> The problem with this syntax is that you can only index one column.  Why
> not do:
> 
>   __PACKAGE__->add_index( idx_foo_bar => [qw/foo bar/] );

How often do you need to know the name of an index? Why not go one
simpler and do:

    __PACKAGE__->add_index(qw/foo bar/);

Which could return the autogenerated name of the index. If you need the
name at a later (more dynamic stage perhaps) then maybe expose the
name generating method as well.

Mark.
-- 
Mark Lawrence



More information about the DBIx-Class mailing list