[Dbix-class] Relationship Bug

Jess Robinson castaway at desert-island.demon.co.uk
Fri Dec 1 21:48:32 GMT 2006


At Fri, 01 Dec 2006 10:25:10 -0700,
Matt Hilliard wrote:
> 
> I believe I've come across a bug in BRICAS/DBIx-Class-0.07003.tar.gz,
> the synopsis is this:  
> I'm running from a Catalyst context, I start with a DBIx::Class with 2
> separate foreign keys to the same foreign table, both initially "NULL",
> for example:
> 
> package DB::Schema::Model;
> 
> use strict;
> use warnings;
> 
> use base 'DBIx::Class';
> 
> __PACKAGE__->load_components("PK::Auto", "Core");
> __PACKAGE__->table("some_table_or_other");
> __PACKAGE__->add_columns(
>   "id",
>   { data_type => "INT", default_value => undef, is_nullable => 0, size
> => 11 },
>   "assorted_other_data",
>   { data_type => "INT", default_value => 0, is_nullable => 0, size =>
> 11 },
>   "curr_address",
>   { data_type => "INT", default_value => undef, is_nullable => 1, size
> => 11 },
>   "prev_address",
>   { data_type => "INT", default_value => undef, is_nullable => 1, size
> => 11 },
> );
> __PACKAGE__->set_primary_key("id");
> 
> __PACKAGE__->might_have("curr_address", "Addresses", { "foreign.id" =>
> "self.curr_address" });
> __PACKAGE__->might_have("prev_address", "Addresses", { "foreign.id" =>
> "self.prev_address" });
> 1;
> 
These relationships are incorrect. might_have means "Another table may contain a row with the primary key of this table". Rename those to "belongs_to" and that'll probably work a lot better.

Jess



More information about the Dbix-class mailing list