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

Jonathan Rockway jon at jrock.us
Wed Apr 2 02:35:38 BST 2008


* 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/] );


> +=head1 USAGE NOTES
> +
> +The module adds indexes by declaring a version of the C<sqlt_deploy_hook> method. If you
> +want to use this component together with your own C<sqlt_deploy_hook>, you need add an
> +explicit inherited method call to your version:
> +
> +    sub sqlt_deploy_hook {
> +        my ($self, $sqlt_table) = @_;
> +
> +        <do your stuff>
> +
> +        $self->next::method ($sqlt_table);  #call sqlt_deploy_hook from Index::Simple
> +    }

This chunk of docs should probably live in a more general place.  It's
not just users of your extension that need to know this.

Regards,
Jonathan Rockway

-- 
print just => another => perl => hacker => if $,=$"



More information about the DBIx-Class mailing list