[Dbix-class] DBIx::Class::Index::Simple
Peter Rabbitson
rabbit+list at rabbit.us
Wed Apr 2 07:47:20 BST 2008
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/] );
>
Ash expressed the same concern and here is what I said:
ribasushi> ash: I was thinking to make add_index a method at first, however it
does not go along with the philosophy of dbic (as far as I see it)
<ribasushi> ->set_primary_key, ->add_unique_constraint - they all have some
meaning for DBIC itself
<ribasushi> where as an index is meaningless, and only SQLT would care about it
<ribasushi> I figured I'll add it as an attribute, just like is_foreign_key is
a column attribute
<ash> what about multi-col indexs tho?
<ribasushi> you still use the hook
<ribasushi> that's why the Simple
Additionally such functionality used to exist but was pulled away in r3815
(trunk), to give way to sqlt_deploy_hook.
Should it get reinstated?
>
>> +=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.
>
Suggestions?
Peter
More information about the DBIx-Class
mailing list