[Dbix-class] How to use DBIx::Class on a view
Nigel Metheringham
nigel.metheringham at dev.intechnology.co.uk
Wed Nov 16 17:43:09 CET 2005
On Tue, 2005-11-15 at 20:06 +0000, Matt S Trout wrote:
> I reckon your primary key is (date,bs_group,feature).
That seems right...
However that gives me another issue. bs_group and feature are keys into
other tables, so I wanted to make them has_one relationships, which gave
me a class content like this.... (slightly shortened):-
__PACKAGE__->table('group_date_feature_map');
__PACKAGE__->add_columns(qw/date bs_group feature count/);
__PACKAGE__->set_primary_key(qw/date bs_group feature/);
# set up the relationships
__PACKAGE__->belong_to(bs_group => 'App::M::Database::BsGroup');
__PACKAGE__->belong_to(feature => 'App::M::Database::Feature');
Now when I try and retrieve some data from this table I get:-
Can't find unless primary columns are defined
at /usr/local/share/perl/5.8.7/DBIx/Class/Relationship/Base.pm
line 260
Tracing the SQL shows that it starts to retrieve the data and then
chokes (presumably whilst trying to add the per-row mapping from this
table to one of the belonging_to tables). Both these related tables are
working OK and are simple tables (PK is an autogenerated id column) -
the problem appears to be with the complex PK on this view table.
[Also, trivial mini-question. Whats the DBIC equivalent to the CDBI
retrieve_all ?]
Nigel.
--
[ Nigel Metheringham Nigel.Metheringham at InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]
More information about the Dbix-class
mailing list