[Dbix-class] __PACKAGE__->add_columns and ->sequence interaction

Adam Sjøgren adsj at novozymes.com
Thu Nov 2 13:11:35 GMT 2006


  Hi.


I just added __PACKAGE__->sequence() calls to my DBIx:Class classes¹. 
It went fine until I reached this one (cut-down example):

 package MyDB::Artist;

 use strict;
 use warnings;

 use base qw/DBIx::Class/;

 __PACKAGE__->load_components(qw/PK::Auto Core/);
 __PACKAGE__->table('music.artist');
 __PACKAGE__->add_columns(qw/id sequence created updated/);
 __PACKAGE__->set_primary_key('id');
 __PACKAGE__->sequence('music.artist_full_id_seq');
 __PACKAGE__->has_many('albums', 'MyDB::Album', 'artist_id');

>From which I got an incomprehensible error-message along the lines of:

 DBIx::Class::Schema::load_classes(): DBIx::Class::Relationship::BelongsTo::belongs_to(): DBIx::Class::Relationship::HasMany::has_many(): DBIx::Class::Relationship::BelongsTo::belongs_to(): Can't locate object method "segments" via package "MyDB::Album" at lib/MyDB/Album.pm line 314.

After staring a little at it, I got a hunch and moved the ->sequence
call up before the __PACKAGE__->add_columns one - and the error went
away.

I'm wondering whether this interaction is a bug, or if I should just
learn to do these things in the "correct" order...?


  Mvh.

   Adam


¹ Because they are (now) views, so the auto-detection does not work
  (for good reasons, I think), but that is another story :-)

-- 
                                                          Adam Sjøgren
                                                    adsj at novozymes.com



More information about the Dbix-class mailing list