[html-formfu] HTML::FormFu::Model::DBIC
t\update\create_belongs_to.t problems
Peter Shangov
pshangov at yahoo.com
Mon Feb 28 16:31:38 GMT 2011
Hi all,
I have been struggling with this for the past couple of hours:
The schema definition in t\lib\MySchema\Band.pm uses a relationship name (‘manager’) identical to the name of the foreign key column through which it is defined, and which runs against the naming conventions in our databases:
__PACKAGE__->add_columns(
id => { data_type => "INTEGER", is_nullable => 0 },
manager => { data_type => "INTEGER", is_nullable => 1 },
…
);
…
__PACKAGE__->belongs_to( manager => 'MySchema::Manager' );
If I change ‘manager’ to ‘manager_id’:
__PACKAGE__->add_columns(
id => { data_type => "INTEGER", is_nullable => 0 },
manager_id => { data_type => "INTEGER", is_nullable => 1 },
);
…
__PACKAGE__->belongs_to( manager => 'MySchema::Manager', ‘manager_id’ );
prove t\update\belongs_to_create.t fails with the following error:
MySchema::Band::manager(): Unable to resolve relationship 'manager' from object MySchema::Band=HASH(0x189d124): column 'manager_id' not loaded from storage (or not passed to new() prior to insert()). You probably need to call ->discard_changes to get the server-side defaults from the database.
Any ideas why this change causes such a difference?
Using:
DBIx::Class 0.08127
HTML::FormFu 0.08002
HTML::FormFu::Model::DBIC 0.08002
Cheers,
--
Peter
More information about the HTML-FormFu
mailing list