[Dbix-class] Another bug in the SQLT parser

Jess Robinson castaway at desert-island.me.uk
Thu Apr 10 16:17:41 BST 2008



On Fri, 4 Apr 2008, Peter Rabbitson wrote:

> There seems to be an additional problem, which lies in the MySQL producer 
> itself (maybe others too). Keeping it in the thread as it is from the same 
> department. Example (a crude linked list):
>
> __PACKAGE__->add_columns (
>    id => {
>        data_type => 'BIGINT',
>        is_auto_increment => 1,
>    },
>    prev_id => {
>        data_type => 'BIGINT',
>        is_foreign_key => 1,
>    },
>
>    name => {
>        data_type => 'VARCHAR',
>        size => 255,
>    },
> );
>
> __PACKAGE__->set_primary_key ('id');
> __PACKAGE__->add_unique_constraint (prev => [qw/prev_id/]);	# enforces 
> 1:1
>
> __PACKAGE__->might_have ('next_option', __PACKAGE__, 'prev_id' );
> __PACKAGE__->belongs_to ('prev_option', __PACKAGE__, 'prev_id', {join_type => 
> 'left' });

Assuming your next_option works the same way as your prev_option, but just 
might be empty, they should both be a "belongs_to", not "might_have".

Jess



More information about the DBIx-Class mailing list